Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoMapperv13 #207

Merged
merged 2 commits into from
Feb 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageId>AutoMapper.AspNetCore.OData.EF6</PackageId>
<Description>Creates LINQ expressions from ODataQueryOptions and executes the query.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Supporting AutoMapper v12.</PackageReleaseNotes>
<PackageReleaseNotes>Supporting AutoMapper v13 (EF Core only).</PackageReleaseNotes>
<PackageTags>linq expressions odata efcore</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/AutoMapper/AutoMapper.Extensions.OData</RepositoryUrl>
Expand Down Expand Up @@ -56,14 +56,16 @@

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[6.0.4,7.0.0)" />
<PackageReference Include="EntityFramework" Version="6.3.0" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[6.0.0,7.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.0.6" />
<PackageReference Include="MinVer" Version="2.5.0">
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.2.4" />
<PackageReference Include="MinVer" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="System.Drawing.Common" Version="4.7.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageId>AutoMapper.AspNetCore.OData.EFCore</PackageId>
<Description>Creates LINQ expressions from ODataQueryOptions and executes the query.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Supporting AutoMapper v12.</PackageReleaseNotes>
<PackageReleaseNotes>Supporting AutoMapper v13 (EF Core only).</PackageReleaseNotes>
<PackageTags>linq expressions odata efcore</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/AutoMapper/AutoMapper.Extensions.OData</RepositoryUrl>
Expand All @@ -28,14 +28,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[6.0.4,7.0.0)" />
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[7.0.0,8.0.0)" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[6.0.0,7.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.0.6" />
<PackageReference Include="MinVer" Version="2.5.0">
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.2.4" />
<PackageReference Include="MinVer" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
Expand All @@ -47,7 +47,7 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
87 changes: 48 additions & 39 deletions AutoMapper.OData.EFCore.Tests/GetQuerySelectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,20 @@

namespace AutoMapper.OData.EFCore.Tests
{
public class GetQuerySelectTests
public class GetQuerySelectTests : IClassFixture<GetQuerySelectTestsFixture>
{
public GetQuerySelectTests()
private readonly GetQuerySelectTestsFixture _fixture;

public GetQuerySelectTests(GetQuerySelectTestsFixture fixture)
{
Initialize();
_fixture = fixture;
serviceProvider = _fixture.ServiceProvider;
}

#region Fields
private IServiceProvider serviceProvider;
private readonly IServiceProvider serviceProvider;
#endregion Fields

private void Initialize()
{
IServiceCollection services = new ServiceCollection();
IMvcCoreBuilder builder = new TestMvcCoreBuilder
{
Services = services
};

builder.AddOData();
services.AddDbContext<MyDbContext>
(
options =>
{
options.UseInMemoryDatabase("MyDbContext");
options.UseInternalServiceProvider(new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider());
},
ServiceLifetime.Transient
)
.AddSingleton<IConfigurationProvider>(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly)))
.AddTransient<IMapper>(sp => new Mapper(sp.GetRequiredService<IConfigurationProvider>(), sp.GetService))
.AddTransient<IApplicationBuilder>(sp => new ApplicationBuilder(sp))
.AddRouting()
.AddLogging();

serviceProvider = services.BuildServiceProvider();

MyDbContext context = serviceProvider.GetRequiredService<MyDbContext>();
context.Database.EnsureCreated();
DatabaseInitializer.SeedDatabase(context);
}

[Fact]
public async void OpsTenantSelectNameExpandBuildings()
{
Expand Down Expand Up @@ -84,7 +56,7 @@ public async void OpsTenantExpandBuildingsFilterEqAndOrderBy_FirstBuildingHasVal

void Test(ICollection<OpsTenant> collection)
{
Assert.Equal(1, collection.Count);
Assert.Single(collection);
Assert.Equal(2, collection.First().Buildings.Count);
Assert.NotNull(collection.First().Buildings.First().Name);
Assert.NotEqual(default, collection.First().Buildings.First().Identity);
Expand All @@ -103,7 +75,7 @@ public async void BuildingSelectNameExpandBuilder_BuilderNameShouldBeSam()

void Test(ICollection<CoreBuilding> collection)
{
Assert.Equal(1, collection.Count);
Assert.Single(collection);
Assert.Equal("Sam", collection.First().Builder.Name);
Assert.Equal(default, collection.First().Builder.Id);
Assert.Null(collection.First().Builder.City);
Expand All @@ -122,7 +94,7 @@ public async void BuildingExpandBuilderSelectNamefilterEqAndOrderBy()

void Test(ICollection<CoreBuilding> collection)
{
Assert.Equal(1, collection.Count);
Assert.Single(collection);
Assert.Equal("Sam", collection.First().Builder.Name);
Assert.Equal(default, collection.First().Builder.Id);
Assert.Null(collection.First().Builder.City);
Expand All @@ -141,7 +113,7 @@ public async void BuildingExpandBuilderSelectNameExpandCityFilterEqAndOrderBy_Ci

void Test(ICollection<CoreBuilding> collection)
{
Assert.Equal(1, collection.Count);
Assert.Single(collection);
Assert.Equal("Sam", collection.First().Builder.Name);
Assert.Equal(default, collection.First().Builder.Id);
Assert.Equal("London", collection.First().Builder.City.Name);
Expand Down Expand Up @@ -220,4 +192,41 @@ private ODataQueryOptions<TModel> GetODataQueryOptions<TModel>(string query, str
);
}
}

public class GetQuerySelectTestsFixture
{
public GetQuerySelectTestsFixture()
{
IServiceCollection services = new ServiceCollection();
IMvcCoreBuilder builder = new TestMvcCoreBuilder
{
Services = services
};

builder.AddOData();
services.AddDbContext<MyDbContext>
(
options => options.UseSqlServer
(
@"Server=(localdb)\mssqllocaldb;Database=GetQuerySelectTestsatabase;ConnectRetryCount=0",
options => options.EnableRetryOnFailure()
),
ServiceLifetime.Transient
)
.AddSingleton<IConfigurationProvider>(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly)))
.AddTransient<IMapper>(sp => new Mapper(sp.GetRequiredService<IConfigurationProvider>(), sp.GetService))
.AddTransient<IApplicationBuilder>(sp => new ApplicationBuilder(sp))
.AddRouting()
.AddLogging();

ServiceProvider = services.BuildServiceProvider();

MyDbContext context = ServiceProvider.GetRequiredService<MyDbContext>();
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
DatabaseInitializer.SeedDatabase(context);
}

internal IServiceProvider ServiceProvider;
}
}
Loading
Loading