Skip to content

Commit d33fab6

Browse files
committed
Support for translating cast operator use / Updating NetStandardPolyfills package to v1.3 / Switching from MsTest to XUnit
1 parent 65d8b9a commit d33fab6

30 files changed

+922
-748
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<configSections>
44
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
5-
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
5+
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
66
</configSections>
77
<entityFramework>
88
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
99
<parameters>
10-
<parameter value="mssqllocaldb" />
10+
<parameter value="mssqllocaldb"/>
1111
</parameters>
1212
</defaultConnectionFactory>
1313
<providers>
14-
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
14+
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
1515
</providers>
1616
</entityFramework>
17-
</configuration>
17+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>

ReadableExpressions.UnitTests/Extensions/WhenGettingAParentExpressionNode.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,53 @@
44
using System.Collections.Generic;
55
using System.Linq;
66
using System.Linq.Expressions;
7-
using Microsoft.VisualStudio.TestTools.UnitTesting;
87
using ReadableExpressions.Extensions;
8+
using Xunit;
99

1010
public class WhenGettingAParentExpressionNode
1111
{
12-
[TestMethod]
12+
[Fact]
1313
public void ShouldReturnAMemberAccessParent()
1414
{
1515
Expression<Func<Type, string>> personViewModelName = t => t.Name;
1616

1717
var namePropertyParent = personViewModelName.Body.GetParentOrNull() as ParameterExpression;
1818

19-
Assert.IsNotNull(namePropertyParent);
20-
Assert.AreEqual("t", namePropertyParent.Name);
19+
Assert.NotNull(namePropertyParent);
20+
Assert.Equal("t", namePropertyParent.Name);
2121
}
2222

23-
[TestMethod]
23+
[Fact]
2424
public void ShouldReturnANestedMemberAccessParent()
2525
{
2626
Expression<Func<Type, string>> typeAssemblyImageVersion = t => t.Assembly.ImageRuntimeVersion;
2727

2828
var typeAssemblyImageVersionParent = typeAssemblyImageVersion.Body.GetParentOrNull() as MemberExpression;
2929

30-
Assert.IsNotNull(typeAssemblyImageVersionParent);
31-
Assert.AreEqual("Assembly", typeAssemblyImageVersionParent.Member.Name);
30+
Assert.NotNull(typeAssemblyImageVersionParent);
31+
Assert.Equal("Assembly", typeAssemblyImageVersionParent.Member.Name);
3232
}
3333

34-
[TestMethod]
34+
[Fact]
3535
public void ShouldReturnAMemberMethodCallParent()
3636
{
3737
Expression<Func<Type, string>> typeAssemblyToString = p => p.Assembly.ToString();
3838

3939
var assemblyToStringPropertyParent = typeAssemblyToString.Body.GetParentOrNull() as MemberExpression;
4040

41-
Assert.IsNotNull(assemblyToStringPropertyParent);
42-
Assert.AreEqual("Assembly", assemblyToStringPropertyParent.Member.Name);
41+
Assert.NotNull(assemblyToStringPropertyParent);
42+
Assert.Equal("Assembly", assemblyToStringPropertyParent.Member.Name);
4343
}
4444

45-
[TestMethod]
45+
[Fact]
4646
public void ShouldReturnAnExtensionMethodCallParent()
4747
{
4848
Expression<Func<IEnumerable<Type>, Type[]>> typesToArray = ts => ts.ToArray();
4949

5050
var typesToArrayPropertyParent = typesToArray.Body.GetParentOrNull() as ParameterExpression;
5151

52-
Assert.IsNotNull(typesToArrayPropertyParent);
53-
Assert.AreEqual("ts", typesToArrayPropertyParent.Name);
52+
Assert.NotNull(typesToArrayPropertyParent);
53+
Assert.Equal("ts", typesToArrayPropertyParent.Name);
5454
}
5555
}
5656
}

ReadableExpressions.UnitTests/Extensions/WhenGettingFriendlyNames.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Linq.Expressions;
6-
using Microsoft.VisualStudio.TestTools.UnitTesting;
76
using ReadableExpressions.Extensions;
7+
using Xunit;
88

9-
[TestClass]
109
public class WhenGettingFriendlyNames
1110
{
12-
[TestMethod]
11+
[Fact]
1312
public void ShouldUseFriendlyNamesForArrays()
1413
{
1514
var intArrayVariable = Expression.Variable(typeof(int[]), "ints");
@@ -18,61 +17,61 @@ public void ShouldUseFriendlyNamesForArrays()
1817

1918
var translated = assignNullBlock.ToReadableString();
2019

21-
Assert.AreEqual("var ints = default(int[]);", translated);
20+
Assert.Equal("var ints = default(int[]);", translated);
2221
}
2322

24-
[TestMethod]
23+
[Fact]
2524
public void ShouldUseFriendlyNamesForCharacters()
2625
{
2726
Expression<Func<char, double>> characterToNumeric = c => char.GetNumericValue(c);
2827

2928
var translated = characterToNumeric.ToReadableString();
3029

31-
Assert.AreEqual("c => char.GetNumericValue(c)", translated);
30+
Assert.Equal("c => char.GetNumericValue(c)", translated);
3231
}
3332

34-
[TestMethod]
33+
[Fact]
3534
public void ShouldUseFriendlyNamesForAnonymousTypes()
3635
{
3736
var anon = new { One = 1, Two = "two" };
3837

3938
var friendlyName = anon.GetType().GetFriendlyName();
4039

41-
Assert.AreEqual("AnonymousType<int, string>", friendlyName);
40+
Assert.Equal("AnonymousType<int, string>", friendlyName);
4241
}
4342

4443
// See https://github.com/agileobjects/ReadableExpressions/issues/6
45-
[TestMethod]
44+
[Fact]
4645
public void ShouldUseFriendlyNamesForMultiplyNestedTypes()
4746
{
4847
var nestedType = Expression.Constant(typeof(OuterClass.InnerClass.Nested), typeof(Type));
4948

5049
var translated = nestedType.ToReadableString();
5150

52-
Assert.AreEqual("typeof(OuterClass.InnerClass.Nested)", translated);
51+
Assert.Equal("typeof(OuterClass.InnerClass.Nested)", translated);
5352
}
5453

55-
[TestMethod]
54+
[Fact]
5655
public void ShouldUseFriendlyNamesForListsOfNestedTypes()
5756
{
5857
var newNestedTypeList = Expression.New(typeof(List<>).MakeGenericType(typeof(OuterClass.InnerClass)));
5958

6059
var translated = newNestedTypeList.ToReadableString();
6160

62-
Assert.AreEqual("new List<OuterClass.InnerClass>()", translated);
61+
Assert.Equal("new List<OuterClass.InnerClass>()", translated);
6362
}
6463

65-
[TestMethod]
64+
[Fact]
6665
public void ShouldUseFriendlyNamesForGenericNestedTypes()
6766
{
6867
var genericListEnumeratorType = Expression.Constant(typeof(List<string>.Enumerator), typeof(Type));
6968

7069
var translated = genericListEnumeratorType.ToReadableString();
7170

72-
Assert.AreEqual("typeof(List<string>.Enumerator)", translated);
71+
Assert.Equal("typeof(List<string>.Enumerator)", translated);
7372
}
7473

75-
[TestMethod]
74+
[Fact]
7675
public void ShouldUseFriendlyNamesForGenericMultiplyNestedTypes()
7776
{
7877
var nestedGenericType = Expression.Constant(
@@ -81,7 +80,7 @@ public void ShouldUseFriendlyNamesForGenericMultiplyNestedTypes()
8180

8281
var translated = nestedGenericType.ToReadableString();
8382

84-
Assert.AreEqual("typeof(OuterGeneric<int>.InnerGeneric<long>.Nested)", translated);
83+
Assert.Equal("typeof(OuterGeneric<int>.InnerGeneric<long>.Nested)", translated);
8584
}
8685
}
8786
}

ReadableExpressions.UnitTests/ReadableExpressions.UnitTests.csproj

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" />
34
<PropertyGroup>
45
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
56
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,14 +9,17 @@
89
<AppDesignerFolder>Properties</AppDesignerFolder>
910
<RootNamespace>AgileObjects.ReadableExpressions.UnitTests</RootNamespace>
1011
<AssemblyName>AgileObjects.ReadableExpressions.UnitTests</AssemblyName>
11-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1213
<FileAlignment>512</FileAlignment>
1314
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1415
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
1516
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
1617
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
1718
<IsCodedUITest>False</IsCodedUITest>
1819
<TestProjectType>UnitTest</TestProjectType>
20+
<NuGetPackageImportStamp>
21+
</NuGetPackageImportStamp>
22+
<TargetFrameworkProfile />
1923
</PropertyGroup>
2024
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2125
<DebugSymbols>true</DebugSymbols>
@@ -35,8 +39,8 @@
3539
<WarningLevel>4</WarningLevel>
3640
</PropertyGroup>
3741
<ItemGroup>
38-
<Reference Include="AgileObjects.NetStandardPolyfills, Version=1.2.1.0, Culture=neutral, PublicKeyToken=06131ac1c008ad4e, processorArchitecture=MSIL">
39-
<HintPath>..\packages\AgileObjects.NetStandardPolyfills.1.2.1\lib\net40\AgileObjects.NetStandardPolyfills.dll</HintPath>
42+
<Reference Include="AgileObjects.NetStandardPolyfills, Version=1.3.0.0, Culture=neutral, PublicKeyToken=06131ac1c008ad4e, processorArchitecture=MSIL">
43+
<HintPath>..\packages\AgileObjects.NetStandardPolyfills.1.3.0\lib\net40\AgileObjects.NetStandardPolyfills.dll</HintPath>
4044
</Reference>
4145
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
4246
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
@@ -46,8 +50,29 @@
4650
</Reference>
4751
<Reference Include="Microsoft.CSharp" />
4852
<Reference Include="System" />
53+
<Reference Include="System.ComponentModel.Composition" />
4954
<Reference Include="System.ComponentModel.DataAnnotations" />
5055
<Reference Include="System.Data" />
56+
<Reference Include="System.IO.Compression" />
57+
<Reference Include="System.Net.Http" />
58+
<Reference Include="System.Numerics" />
59+
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
60+
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
61+
</Reference>
62+
<Reference Include="System.Xml" />
63+
<Reference Include="System.Xml.Linq" />
64+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
65+
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
66+
</Reference>
67+
<Reference Include="xunit.assert, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
68+
<HintPath>..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
69+
</Reference>
70+
<Reference Include="xunit.core, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
71+
<HintPath>..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll</HintPath>
72+
</Reference>
73+
<Reference Include="xunit.execution.desktop, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
74+
<HintPath>..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll</HintPath>
75+
</Reference>
5176
</ItemGroup>
5277
<Choose>
5378
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
@@ -105,6 +130,9 @@
105130
<None Include="App.config" />
106131
<None Include="packages.config" />
107132
</ItemGroup>
133+
<ItemGroup>
134+
<Analyzer Include="..\packages\xunit.analyzers.0.8.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
135+
</ItemGroup>
108136
<Choose>
109137
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
110138
<ItemGroup>
@@ -125,6 +153,14 @@
125153
</Choose>
126154
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
127155
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
156+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
157+
<PropertyGroup>
158+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
159+
</PropertyGroup>
160+
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.props'))" />
161+
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.targets'))" />
162+
</Target>
163+
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" />
128164
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
129165
Other similar extension points exist, see Microsoft.Common.targets.
130166
<Target Name="BeforeBuild">

0 commit comments

Comments
 (0)