Skip to content

Commit 6c4ab1b

Browse files
committed
example test case
1 parent 7a50ed8 commit 6c4ab1b

14 files changed

+207
-13
lines changed
File renamed without changes.
Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
1+
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.3.32804.467
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.All", "AutSoft.All\AutSoft.All.csproj", "{D5954B94-5C9C-4787-A2A6-3CC7D00EEFEA}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.All", ".\src\AutSoft.All\AutSoft.All.csproj", "{D5954B94-5C9C-4787-A2A6-3CC7D00EEFEA}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.Linq", "AutSoft.Linq\AutSoft.Linq.csproj", "{A03DAE6A-B41A-4037-B639-F973C6961BB2}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.Linq", ".\src\AutSoft.Linq\AutSoft.Linq.csproj", "{A03DAE6A-B41A-4037-B639-F973C6961BB2}"
99
EndProject
10-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.DbScaffolding", "AutSoft.DbScaffolding\AutSoft.DbScaffolding.csproj", "{AF506C20-DD0A-4EA8-994E-E38ADC225962}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.DbScaffolding", ".\src\AutSoft.DbScaffolding\AutSoft.DbScaffolding.csproj", "{AF506C20-DD0A-4EA8-994E-E38ADC225962}"
1111
EndProject
12-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.DbScaffolding.Identity", "AutSoft.DbScaffolding.Identity\AutSoft.DbScaffolding.Identity.csproj", "{FF908529-9DDE-4DFB-ABA9-A2045E715B21}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.DbScaffolding.Identity", ".\src\AutSoft.DbScaffolding.Identity\AutSoft.DbScaffolding.Identity.csproj", "{FF908529-9DDE-4DFB-ABA9-A2045E715B21}"
13+
EndProject
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.Common", ".\src\AutSoft.Core\AutSoft.Common.csproj", "{28371EF8-D3D3-40CA-AAE9-29D80AE0BF3F}"
15+
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{7029D162-AEB0-4B68-A21E-90ABCD21DAD3}"
17+
EndProject
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.Linq.Tests", ".\test\AutSoft.Linq.Tests\AutSoft.Linq.Tests.csproj", "{D4D62897-E6D6-484E-AE4E-F3A0347ADD88}"
19+
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}"
1321
EndProject
1422
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{4E394277-2CC7-43A6-BB85-E13E44F27F9E}"
1523
ProjectSection(SolutionItems) = preProject
1624
.editorconfig = .editorconfig
17-
..\pipelines\autsoft-core-packages-cd.yml = ..\pipelines\autsoft-core-packages-cd.yml
18-
Directory.Build.props = Directory.Build.props
19-
Directory.Packages.props = Directory.Packages.props
20-
..\pipelines\GitVersion.yml = ..\pipelines\GitVersion.yml
25+
pipelines\autsoft-core-packages-cd.yml = pipelines\autsoft-core-packages-cd.yml
26+
src\Directory.Build.props = src\Directory.Build.props
27+
src\Directory.Packages.props = src\Directory.Packages.props
28+
pipelines\GitVersion.yml = pipelines\GitVersion.yml
2129
LICENSE.md = LICENSE.md
22-
..\README.md = ..\README.md
30+
README.md = README.md
2331
EndProjectSection
2432
EndProject
25-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutSoft.Common", "AutSoft.Core\AutSoft.Common.csproj", "{28371EF8-D3D3-40CA-AAE9-29D80AE0BF3F}"
26-
EndProject
2733
Global
2834
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2935
Debug|Any CPU = Debug|Any CPU
@@ -50,10 +56,22 @@ Global
5056
{28371EF8-D3D3-40CA-AAE9-29D80AE0BF3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
5157
{28371EF8-D3D3-40CA-AAE9-29D80AE0BF3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
5258
{28371EF8-D3D3-40CA-AAE9-29D80AE0BF3F}.Release|Any CPU.Build.0 = Release|Any CPU
59+
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
60+
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88}.Debug|Any CPU.Build.0 = Debug|Any CPU
61+
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88}.Release|Any CPU.ActiveCfg = Release|Any CPU
62+
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88}.Release|Any CPU.Build.0 = Release|Any CPU
5363
EndGlobalSection
5464
GlobalSection(SolutionProperties) = preSolution
5565
HideSolutionNode = FALSE
5666
EndGlobalSection
67+
GlobalSection(NestedProjects) = preSolution
68+
{D5954B94-5C9C-4787-A2A6-3CC7D00EEFEA} = {C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}
69+
{A03DAE6A-B41A-4037-B639-F973C6961BB2} = {C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}
70+
{AF506C20-DD0A-4EA8-994E-E38ADC225962} = {C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}
71+
{FF908529-9DDE-4DFB-ABA9-A2045E715B21} = {C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}
72+
{28371EF8-D3D3-40CA-AAE9-29D80AE0BF3F} = {C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}
73+
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88} = {7029D162-AEB0-4B68-A21E-90ABCD21DAD3}
74+
EndGlobalSection
5775
GlobalSection(ExtensibilityGlobals) = postSolution
5876
SolutionGuid = {E4767DF1-41A6-4BF0-A957-2718986D8BC7}
5977
EndGlobalSection

src/Directory.Packages.props

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>
2020
</ItemGroup>
21-
</Project>
21+
<ItemGroup>
22+
<PackageVersion Include="Microsoft.NET.Test.Sdk">
23+
<Version>17.3.0</Version>
24+
</PackageVersion>
25+
<PackageVersion Include="xunit">
26+
<Version>2.4.2</Version>
27+
</PackageVersion>
28+
<PackageVersion Include="xunit.runner.visualstudio">
29+
<Version>2.4.5</Version>
30+
</PackageVersion>
31+
</ItemGroup>
32+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="AutoMapper" Version="11.0.1" />
13+
<PackageReference Include="Bogus" Version="34.0.2" />
14+
<PackageReference Include="FluentAssertions" Version="6.7.0" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.8" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
17+
<PackageReference Include="Moq" Version="4.18.2" />
18+
<PackageReference Include="xunit" Version="2.4.1" />
19+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
23+
<PackageReference Include="coverlet.collector" Version="3.1.2">
24+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
25+
<PrivateAssets>all</PrivateAssets>
26+
</PackageReference>
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<ProjectReference Include="..\..\src\AutSoft.Linq\AutSoft.Linq.csproj" />
31+
</ItemGroup>
32+
33+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace AutSoft.Linq.Tests.Queryable.OrderByExtensions;
2+
3+
public partial class IsSortable : OrderByExtensionsTests
4+
{
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace AutSoft.Linq.Tests.Queryable.OrderByExtensions;
2+
3+
public partial class OrderByFluent : OrderByExtensionsTests
4+
{
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace AutSoft.Linq.Tests.Queryable.OrderByExtensions;
2+
3+
public partial class OrderByFromEFModel : OrderByExtensionsTests
4+
{
5+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using AutoMapper.QueryableExtensions;
2+
3+
using AutSoft.Linq.Models;
4+
using AutSoft.Linq.Queryable;
5+
6+
using FluentAssertions;
7+
8+
using System.Linq.Expressions;
9+
10+
namespace AutSoft.Linq.Tests.Queryable.OrderByExtensions;
11+
12+
public partial class OrderByFromMappings : OrderByExtensionsTests
13+
{
14+
[Theory]
15+
[InlineData(nameof(PersonDto.Id))]
16+
[InlineData(nameof(PersonDto.Name))]
17+
[InlineData(nameof(PersonDto.Age))]
18+
public async Task Should_ReturnOrdered(string orderBy)
19+
{
20+
// Act
21+
var ordered = Subject
22+
.OrderBy<Person, PersonDto>(new PageRequest { OrderBy = orderBy }, p => p.Id, Mapper.ConfigurationProvider)
23+
.ProjectTo<PersonDto>(Mapper.ConfigurationProvider)
24+
.ToList();
25+
26+
// Assert
27+
ordered.Should().HaveCount(Subject.Count());
28+
ordered.Should().BeInAscendingOrder(orderBy switch
29+
{
30+
nameof(PersonDto.Id) => (Expression<Func<PersonDto, object>>)(p => p.Id),
31+
nameof(PersonDto.Name) => p => p.Name,
32+
nameof(PersonDto.Age) => p => p.Age,
33+
_ => throw new NotSupportedException("Not valid test case input"),
34+
});
35+
}
36+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace AutSoft.Linq.Tests.Queryable.OrderByExtensions;
2+
3+
public partial class ThenByFluent : OrderByExtensionsTests
4+
{
5+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using AutoMapper;
2+
3+
using Bogus;
4+
5+
namespace AutSoft.Linq.Tests.Queryable.OrderByExtensions;
6+
7+
public partial class OrderByExtensionsTests : IDisposable
8+
{
9+
public OrderByExtensionsTests()
10+
{
11+
Faker = new Faker<Person>()
12+
.RuleFor(x => x.Id, f => f.IndexGlobal + 1)
13+
.RuleFor(x => x.Name, f => f.Person.FullName)
14+
.RuleFor(x => x.Address, f => f.Person.Address.ToString())
15+
.RuleFor(x => x.DateOfBirth, f => f.Person.DateOfBirth);
16+
17+
Mapper = new MapperConfiguration(
18+
cfg => cfg.CreateMap<Person, PersonDto>()
19+
.ForMember(p => p.Age, opt => opt.MapFrom(p => (DateTimeOffset.UtcNow - p.DateOfBirth).Days / 365)))
20+
.CreateMapper();
21+
22+
DbContext = new PersonDbContext();
23+
DbContext.People.AddRange(Faker.GenerateBetween(9, 21));
24+
DbContext.SaveChanges();
25+
26+
Subject = DbContext.People;
27+
}
28+
29+
private protected IQueryable<Person> Subject { get; set; }
30+
31+
private protected Faker<Person> Faker { get; }
32+
private protected IMapper Mapper { get; }
33+
private protected PersonDbContext DbContext { get; }
34+
35+
public void Dispose()
36+
{
37+
DbContext.Dispose();
38+
}
39+
}

0 commit comments

Comments
 (0)