Upgrade test framework versions and fix test issues

This commit is contained in:
Nate McMaster 2017-05-15 14:19:24 -07:00
parent eedcca1be9
commit 7199e8d358
7 changed files with 30 additions and 48 deletions

View File

@ -4,7 +4,7 @@
<InternalAspNetCoreSdkVersion>2.1.0-*</InternalAspNetCoreSdkVersion>
<MoqVersion>4.7.1</MoqVersion>
<NETStandardImplicitPackageVersion>$(BundledNETStandardPackageVersion)</NETStandardImplicitPackageVersion>
<TestSdkVersion>15.0.0</TestSdkVersion>
<XunitVersion>2.2.0</XunitVersion>
<TestSdkVersion>15.3.0-*</TestSdkVersion>
<XunitVersion>2.3.0-beta2-*</XunitVersion>
</PropertyGroup>
</Project>

View File

@ -22,8 +22,4 @@
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>

View File

@ -29,8 +29,4 @@
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>

View File

@ -19,8 +19,4 @@
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>

View File

@ -29,8 +29,4 @@
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>

View File

@ -20,8 +20,8 @@ namespace Microsoft.Extensions.Internal.Test
public static TheoryData CanGetStackTraceData => new TheoryData<Action, string>
{
{
ThrowsException,
$"{typeof(StackTraceTest).GetTypeInfo().FullName}.{nameof(ThrowsException)}()"
TestMethods.ThrowsException,
$"{typeof(TestMethods).GetTypeInfo().FullName}.{nameof(TestMethods.ThrowsException)}()"
},
{
new ExceptionType().MethodThatThrows,
@ -84,19 +84,18 @@ namespace Microsoft.Extensions.Internal.Test
{
get
{
var thisType = typeof(StackTraceTest);
var intParse = ((Func<string, int>)int.Parse).GetMethodInfo();
var dateTimeOffsetTryParse = typeof(DateTimeOffset).GetMethods()
.First(m => m.Name == nameof(DateTimeOffset.TryParse) && m.GetParameters().Length == 2);
var genericTypeMethod = typeof(List<Process>).GetMethod(nameof(List<Process>.Remove));
var genericMethod = thisType.GetMethod(nameof(GenericMethod));
var multiGenericMethod = thisType.GetMethod(nameof(MultiParameterGenericMethod));
var byRefMethod = thisType.GetMethod(nameof(ByRefMethod));
var asyncMethod = thisType.GetMethod(nameof(AsyncMethod));
var nullableParam = thisType.GetMethod(nameof(MethodWithNullableParams));
var nestedMethod = thisType.GetNestedType(nameof(NestedType), BindingFlags.Public)
var genericMethod = typeof(TestMethods).GetMethod(nameof(TestMethods.GenericMethod));
var multiGenericMethod = typeof(TestMethods).GetMethod(nameof(TestMethods.MultiParameterGenericMethod));
var byRefMethod = typeof(TestMethods).GetMethod(nameof(TestMethods.ByRefMethod));
var asyncMethod = typeof(TestMethods).GetMethod(nameof(TestMethods.AsyncMethod));
var nullableParam = typeof(TestMethods).GetMethod(nameof(TestMethods.MethodWithNullableParams));
var nestedMethod = typeof(StackTraceTest).GetNestedType(nameof(NestedType), BindingFlags.Public)
.GetMethod(nameof(NestedType.NestedMethod));
var nestedGenericMethod = thisType.GetNestedType(nameof(NestedType), BindingFlags.Public)
var nestedGenericMethod = typeof(StackTraceTest).GetNestedType(nameof(NestedType), BindingFlags.Public)
.GetMethod(nameof(NestedType.NestedGenericMethod));
return new TheoryData<MethodBase, string>
@ -104,11 +103,11 @@ namespace Microsoft.Extensions.Internal.Test
{ intParse, "int.Parse(string s)" },
{ dateTimeOffsetTryParse, "System.DateTimeOffset.TryParse(string input, out DateTimeOffset result)" },
{ genericTypeMethod, "System.Collections.Generic.List<System.Diagnostics.Process>.Remove(Process item)" },
{ genericMethod, $"{thisType}.{nameof(GenericMethod)}<TVal>(TVal value)" },
{ multiGenericMethod, $"{thisType}.{nameof(MultiParameterGenericMethod)}<TKey, TVal>(KeyValuePair<TKey, TVal> keyValuePair)" },
{ byRefMethod, $"{thisType}.{nameof(ByRefMethod)}(int a, CultureInfo b, ref long c)" },
{ asyncMethod, $"{thisType}.{nameof(AsyncMethod)}(string name)" },
{ nullableParam, $"{thisType}.{nameof(MethodWithNullableParams)}(Nullable<int> name, string value)" },
{ genericMethod, $"{typeof(TestMethods)}.{nameof(TestMethods.GenericMethod)}<TVal>(TVal value)" },
{ multiGenericMethod, $"{typeof(TestMethods)}.{nameof(TestMethods.MultiParameterGenericMethod)}<TKey, TVal>(KeyValuePair<TKey, TVal> keyValuePair)" },
{ byRefMethod, $"{typeof(TestMethods)}.{nameof(TestMethods.ByRefMethod)}(int a, CultureInfo b, ref long c)" },
{ asyncMethod, $"{typeof(TestMethods)}.{nameof(TestMethods.AsyncMethod)}(string name)" },
{ nullableParam, $"{typeof(TestMethods)}.{nameof(TestMethods.MethodWithNullableParams)}(Nullable<int> name, string value)" },
{ nestedMethod, $"{typeof(NestedType)}.{nameof(NestedType.NestedMethod)}(string value)" },
{ nestedGenericMethod, $"{typeof(NestedType)}.{nameof(NestedType.NestedGenericMethod)}<TKey>(NestedParameterType a, TKey key)" }
};
@ -126,23 +125,26 @@ namespace Microsoft.Extensions.Internal.Test
Assert.Equal(expected, actual.ToString());
}
public static void ThrowsException()
public class TestMethods
{
throw new Exception();
}
public static void ThrowsException()
{
throw new Exception();
}
public string GenericMethod<TVal>(TVal value) => value.ToString();
public string GenericMethod<TVal>(TVal value) => value.ToString();
public void MultiParameterGenericMethod<TKey, TVal>(KeyValuePair<TKey, TVal> keyValuePair)
{
}
public void MultiParameterGenericMethod<TKey, TVal>(KeyValuePair<TKey, TVal> keyValuePair)
{
}
public decimal ByRefMethod(int a, CultureInfo b, ref long c) => a + c;
public decimal ByRefMethod(int a, CultureInfo b, ref long c) => a + c;
public async Task<object> AsyncMethod(string name) => await Task.FromResult(0);
public async Task<object> AsyncMethod(string name) => await Task.FromResult(0);
public void MethodWithNullableParams(int? name, string value)
{
public void MethodWithNullableParams(int? name, string value)
{
}
}
public class NestedType

View File

@ -21,8 +21,4 @@
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>