Skip to content

Commit a0dafb8

Browse files
committed
Shame we cannot use SQLite for the
DbContext Extensions testing
1 parent f937a30 commit a0dafb8

File tree

108 files changed

+137949
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+137949
-0
lines changed

.editorconfig

Lines changed: 380 additions & 0 deletions
Large diffs are not rendered by default.

.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="coverlet.collector" Version="6.0.4">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
</PackageReference>
15+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.7" />
16+
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="9.7.0" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
18+
<PackageReference Include="Shouldly" Version="4.3.0" />
19+
<PackageReference Include="xunit" Version="2.9.3" />
20+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3">
21+
<PrivateAssets>all</PrivateAssets>
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
</PackageReference>
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<Using Include="Xunit" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<ProjectReference Include="..\DbContextHelpers\DbContextHelpers.csproj" />
32+
</ItemGroup>
33+
34+
</Project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using AStar.Dev.Infrastructure.FilesDb.Data;
2+
using AStar.Dev.Infrastructure.FilesDb.Models;
3+
using DbContextHelpers.Fixtures;
4+
using Shouldly;
5+
6+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
7+
8+
public class FileDetailDirectoryNameExtensionsShould : IClassFixture<FilesContextFixture>
9+
{
10+
private readonly FilesContextFixture filesContextFixture;
11+
12+
public FileDetailDirectoryNameExtensionsShould(FilesContextFixture filesContextFixture) => this.filesContextFixture = filesContextFixture;
13+
14+
[Fact]
15+
public void ShouldReturnExpectedFileDetailsWhenDirectoryNameSpecifiedAndRecursionIsFalse()
16+
{
17+
var searchDirectory = new DirectoryName(@"\one-level\");
18+
19+
var sut = filesContextFixture.SutWithFileDetails;
20+
21+
var result = sut.FileDetails.WhereDirectoryNameMatches(searchDirectory.Value, false).ToList();
22+
23+
result.Count.ShouldBe(457);
24+
}
25+
26+
[Fact]
27+
public void ShouldReturnExpectedFileDetailsWhenDirectoryNameSpecifiedAndRecursionIsTrue()
28+
{
29+
var searchDirectory = new DirectoryName(@"\with");
30+
31+
var sut = filesContextFixture.SutWithFileDetails;
32+
33+
var result = sut.FileDetails.WhereDirectoryNameMatches(searchDirectory.Value, true).ToList();
34+
35+
result.Count.ShouldBe(1084);
36+
}
37+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using AStar.Dev.Infrastructure.FilesDb.Data;
2+
using DbContextHelpers.Fixtures;
3+
using Microsoft.Extensions.Time.Testing;
4+
using Shouldly;
5+
6+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
7+
8+
public class FilesContextLastViewedExtensionsShould : IClassFixture<FilesContextFixture>
9+
{
10+
private readonly FilesContextFixture filesContextFixture;
11+
private readonly FakeTimeProvider mockTimeProvider = new();
12+
13+
public FilesContextLastViewedExtensionsShould(FilesContextFixture filesContextFixture)
14+
{
15+
this.filesContextFixture = filesContextFixture;
16+
mockTimeProvider.SetUtcNow(new DateTime(2025, 07, 21, 0, 0, 0, DateTimeKind.Utc));
17+
}
18+
19+
[Fact]
20+
public void ShouldReturnExpectedFileDetailsWhereLastViewedIsSetTo7Days()
21+
{
22+
var sut = filesContextFixture.SutWithFileDetails;
23+
24+
var result = sut.FileDetails.WhereLastViewedIsOlderThan(7, mockTimeProvider).ToList();
25+
26+
result.Count.ShouldBe(1002);
27+
}
28+
29+
[Fact]
30+
public void ShouldReturnExpectedFileDetailsWhereLastViewedIsSetTo0Days()
31+
{
32+
var sut = filesContextFixture.SutWithFileDetails;
33+
34+
var result = sut.FileDetails.WhereLastViewedIsOlderThan(0, mockTimeProvider).ToList();
35+
36+
result.Count.ShouldBe(2000);
37+
}
38+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<ApplicationIcon>astar.ico</ApplicationIcon>
8+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
9+
<Authors>AStar Developement, Jason Barden</Authors>
10+
<Copyright>AStar Developement, 2025</Copyright>
11+
<PackageProjectUrl>https://github.com/astar-development/</PackageProjectUrl>
12+
<RepositoryUrl>https://github.com/astar-development/</RepositoryUrl>
13+
<RepositoryType>git</RepositoryType>
14+
<IncludeSymbols>True</IncludeSymbols>
15+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
16+
<PackageReadmeFile>Readme.md</PackageReadmeFile>
17+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
18+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
19+
<DocumentationFile>$(AssemblyName).xml</DocumentationFile>
20+
</PropertyGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="AStar.Dev.Functional.Extensions" Version="0.2.0" />
24+
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.0.15" />
25+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.7" />
26+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.7">
27+
<PrivateAssets>all</PrivateAssets>
28+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
29+
</PackageReference>
30+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
31+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.7">
32+
<PrivateAssets>all</PrivateAssets>
33+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
34+
</PackageReference>
35+
</ItemGroup>
36+
37+
<ItemGroup>
38+
<None Include="LICENSE" Pack="true" PackagePath="" />
39+
<None Include="Readme.md" Pack="true" PackagePath="" />
40+
</ItemGroup>
41+
42+
<ItemGroup>
43+
<ProjectReference Include="..\AStar.Dev.Infrastructure\AStar.Dev.Infrastructure.csproj" />
44+
<ProjectReference Include="..\AStar.Dev.Technical.Debt.Reporting\AStar.Dev.Technical.Debt.Reporting.csproj" />
45+
<ProjectReference Include="..\AStar.Dev.Utilities\AStar.Dev.Utilities.csproj" />
46+
</ItemGroup>
47+
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
49+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
50+
<NoWarn>1701;1702;</NoWarn>
51+
</PropertyGroup>
52+
53+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
54+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
55+
<NoWarn>1701;1702;</NoWarn>
56+
</PropertyGroup>
57+
58+
</Project>

0 commit comments

Comments
 (0)