Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/codecoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet run --project "EstateReportingAPI.Tests\EstateReportingAPI.Tests.csproj" --configuration Release --no-build -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --results-directory "./coverage/unit"
dotnet run --project "EstateReportingAPI.BusinessLogic.UnitTests\EstateReportingAPI.BusinessLogic.UnitTests.csproj" --configuration Release --no-build -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --results-directory "./coverage/unit"

- name: Build Docker Image
run: docker build . --file EstateReportingAPI/Dockerfile --tag estatereportingapi:latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet run --project "EstateReportingAPI.Tests\EstateReportingAPI.Tests.csproj" --configuration Release --no-build -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --results-directory "./coverage/unit"
dotnet run --project "EstateReportingAPI.BusinessLogic.UnitTests\EstateReportingAPI.BusinessLogic.UnitTests.csproj" --configuration Release --no-build -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --results-directory "./coverage/unit"

- name: Build Docker Image
run: docker build . --file EstateReportingAPI/Dockerfile --tag estatereportingapi:latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet run --project "EstateReportingAPI.Tests\EstateReportingAPI.Tests.csproj" --configuration Release --no-build
dotnet run --project "EstateReportingAPI.BusinessLogic.UnitTests\EstateReportingAPI.BusinessLogic.UnitTests.csproj" --configuration Release --no-build

- name: Run Integration Tests
run: |
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.11" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Imposter" Version="0.1.9" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.2.3" />
<PackageVersion Include="TransactionProcessor.Database" Version="2026.8.1" />
Expand Down Expand Up @@ -52,4 +52,4 @@
<PackageVersion Include="NLog" Version="6.2.0" />
<PackageVersion Include="SecurityService.Client" Version="2026.8.1" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -16,9 +18,9 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="Imposter" />
Comment thread
StuartFerguson marked this conversation as resolved.
Resolved
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
38 changes: 23 additions & 15 deletions EstateReportingAPI.BusinessLogic.UnitTests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
using TransactionProcessor.Database.Contexts;
using TransactionProcessor.Database.Entities;
using EstateReportingAPI.BusinessLogic.Queries;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Shared.EntityFramework;
using Imposter.Abstractions;

[assembly: GenerateImposter(typeof(Shared.EntityFramework.IDbContextResolver<EstateManagementContext>))]

namespace EstateReportingAPI.BusinessLogic.UnitTests
{
using EstateManagement.Database.Contexts;
using EstateManagement.Database.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Moq;
using Shouldly;

public class ReportingManagerTests
Expand All @@ -28,11 +33,11 @@ public class TestData{
public async Task ReportingManager_GetCalendarYears_YearsAreReturned(){

//Required properties '{'DayOfWeek', 'DayOfWeekShort', 'MonthNameLong', 'MonthNameShort', 'WeekNumberString', 'YearWeekNumber'}'
var options = new DbContextOptionsBuilder<EstateManagementGenericContext>()
var options = new DbContextOptionsBuilder<EstateManagementContext>()
.UseInMemoryDatabase(databaseName: "TestDatabase")
.Options;

EstateManagementGenericContext context = new EstateManagementSqlServerContext(options);
EstateManagementContext context = new EstateManagementContext(options);
await context.Database.EnsureCreatedAsync();

await context.Calendar.AddRangeAsync(new Calendar{
Expand Down Expand Up @@ -68,17 +73,20 @@ await context.Calendar.AddRangeAsync(new Calendar{
Year = 2021
});
await context.SaveChangesAsync();
Mock<Shared.EntityFramework.IDbContextFactory<EstateManagementGenericContext>> resolver = new Mock<Shared.EntityFramework.IDbContextFactory<EstateManagementGenericContext>>();
resolver.Setup(r => r.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
var services = new ServiceCollection()
.AddDbContext<EstateManagementContext>(builder => builder.UseInMemoryDatabase("TestDatabase"))
.BuildServiceProvider();
var resolver = new IDbContextResolverImposter<EstateManagementContext>();
resolver.Resolve(Arg<String>.Any(), Arg<String>.Any()).Returns(new ResolvedDbContext<EstateManagementContext>(services.CreateScope()));

var manager = new ReportingManager(resolver.Object);
var manager = new ReportingManager(resolver.Instance());

var years = await manager.GetCalendarYears(TestData.EstateId, CancellationToken.None);
var years = await manager.GetCalendarYears(new CalendarQueries.GetYearsQuery(TestData.EstateId), CancellationToken.None);

years.Count.ShouldBe(3);
years.ShouldContain(2021);
years.ShouldContain(2022);
years.ShouldContain(2023);
years.Data.Count.ShouldBe(3);
years.Data.ShouldContain(2021);
years.Data.ShouldContain(2022);
years.Data.ShouldContain(2023);
}
}
}
1 change: 0 additions & 1 deletion EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="Shouldly" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="TransactionProcessor.Database" />
Expand Down
7 changes: 7 additions & 0 deletions EstateReportingAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateReportingAPI.Models",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateReportingAPI.IntegrationTests", "EstateReportingAPI.IntegrationTests\EstateReportingAPI.IntegrationTests.csproj", "{85555B3A-FC04-4291-B0CB-F0835AC23D3E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateReportingAPI.BusinessLogic.UnitTests", "EstateReportingAPI.BusinessLogic.UnitTests\EstateReportingAPI.BusinessLogic.UnitTests.csproj", "{E92B7A1C-4D67-4A0E-9D31-8B6D2F3C5A70}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A296632F-ABDB-4D3E-9351-51346C70C08A}"
EndProject
Global
Expand Down Expand Up @@ -57,6 +59,10 @@ Global
{85555B3A-FC04-4291-B0CB-F0835AC23D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85555B3A-FC04-4291-B0CB-F0835AC23D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85555B3A-FC04-4291-B0CB-F0835AC23D3E}.Release|Any CPU.Build.0 = Release|Any CPU
{E92B7A1C-4D67-4A0E-9D31-8B6D2F3C5A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E92B7A1C-4D67-4A0E-9D31-8B6D2F3C5A70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E92B7A1C-4D67-4A0E-9D31-8B6D2F3C5A70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E92B7A1C-4D67-4A0E-9D31-8B6D2F3C5A70}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -69,6 +75,7 @@ Global
{B71070E8-85FC-4C22-BF94-4E56D477466F} = {713556C8-BFC0-4AB6-8F13-7631C1C82D07}
{B3BE4743-D80E-4247-BAC0-1224D5A6D472} = {713556C8-BFC0-4AB6-8F13-7631C1C82D07}
{85555B3A-FC04-4291-B0CB-F0835AC23D3E} = {C48C544B-7C3B-4AA2-8A37-E49296A86499}
{E92B7A1C-4D67-4A0E-9D31-8B6D2F3C5A70} = {C48C544B-7C3B-4AA2-8A37-E49296A86499}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B2BE269B-F142-45A3-9B75-483227C765A6}
Expand Down
Loading