mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-06-11 09:48:19 +00:00
Add project files.
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="1.3.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\EntityFrameworkCore.Projections\EntityFrameworkCore.Projections.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EntityFrameworkCore.Projections.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace EntityFrameworkCore.Projections.Tests.Extensions
|
||||
{
|
||||
public class TypeExtensionTests
|
||||
{
|
||||
class InnerType
|
||||
{
|
||||
public class SubsequentlyInnerType
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetNestedTypePath_OuterType_Returns1Entry()
|
||||
{
|
||||
var subject = typeof(TypeExtensionTests);
|
||||
|
||||
var result = subject.GetNestedTypePath();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void GetNestedTypePath_InnerType_Returns2Entries()
|
||||
{
|
||||
var subject = typeof(InnerType);
|
||||
|
||||
var result = subject.GetNestedTypePath();
|
||||
|
||||
Assert.Equal(2, result.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetNestedTypePath_SubsequentlyInnerType_Returns3Entries()
|
||||
{
|
||||
var subject = typeof(InnerType.SubsequentlyInnerType);
|
||||
|
||||
var result = subject.GetNestedTypePath();
|
||||
|
||||
Assert.Equal(3, result.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetNestedTypePath_SubsequentlyInnerType_ReturnsTypesInOrder()
|
||||
{
|
||||
var subject = typeof(InnerType.SubsequentlyInnerType);
|
||||
|
||||
var result = subject.GetNestedTypePath();
|
||||
|
||||
Assert.Equal(typeof(TypeExtensionTests), result.First());
|
||||
Assert.Equal(typeof(InnerType.SubsequentlyInnerType), result.Last());
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EntityFrameworkCore.Projections.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace EntityFrameworkCore.Projections.Tests.Services
|
||||
{
|
||||
public class ProjectionExpressionClassNameGeneratorTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("ns", new string[] { "a" }, "m", "ns_a_m")]
|
||||
[InlineData("ns", new string[] { "a", "b" }, "m", "ns_a_b_m")]
|
||||
[InlineData(null, new string[] { "a" }, "m", "_a_m")]
|
||||
public void GenerateName(string? namespaceName, string[] nestedTypeNames, string memberName, string expected)
|
||||
{
|
||||
var result = ProjectionExpressionClassNameGenerator.GenerateName(namespaceName, nestedTypeNames, memberName);
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratedFullName()
|
||||
{
|
||||
var expected = $"{ProjectionExpressionClassNameGenerator.Namespace}.{ProjectionExpressionClassNameGenerator.GenerateName("a", new[] { "b" }, "m")}";
|
||||
var result = ProjectionExpressionClassNameGenerator.GenerateFullName("a", new [] { "b" }, "m");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user