Update unit test project settings (#45)

This commit is contained in:
Alexander Kozlenko 2018-02-02 02:36:46 +02:00 committed by Ben Adams
parent 1d0a516361
commit 286d0e4c44
5 changed files with 33 additions and 35 deletions

View File

@ -2,12 +2,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
namespace Demystify namespace Ben.Demystifier.Test
{ {
public class AggregateException public class AggregateException
{ {
@ -38,7 +37,7 @@ namespace Demystify
var trace = string.Join("", stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) var trace = string.Join("", stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
// Remove items that vary between test runners // Remove items that vary between test runners
.Where(s => .Where(s =>
s != " at Task Demystify.DynamicCompilation.DoesNotPreventStackTrace()+() => { }" && s != " at Task Ben.Demystifier.Test.DynamicCompilation.DoesNotPreventStackTrace()+() => { }" &&
!s.Contains("System.Threading.Tasks.Task.WaitAll") !s.Contains("System.Threading.Tasks.Task.WaitAll")
) )
.Skip(1) .Skip(1)
@ -47,19 +46,19 @@ namespace Demystify
.Replace("<---", ""); .Replace("<---", "");
var expected = string.Join("", new[] { var expected = string.Join("", new[] {
" at async Task Demystify.AggregateException.Throw1()", " at async Task Ben.Demystifier.Test.AggregateException.Throw1()",
" at async void Demystify.AggregateException.DemystifiesAggregateExceptions()+(?) => { }", " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }",
" --- End of inner exception stack trace ---", " --- End of inner exception stack trace ---",
" at void Demystify.AggregateException.DemystifiesAggregateExceptions()", " at void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()",
"---> (Inner Exception #0) System.ArgumentException: Value does not fall within the expected range.", "---> (Inner Exception #0) System.ArgumentException: Value does not fall within the expected range.",
" at async Task Demystify.AggregateException.Throw1()", " at async Task Ben.Demystifier.Test.AggregateException.Throw1()",
" at async void Demystify.AggregateException.DemystifiesAggregateExceptions()+(?) => { }", " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }",
"---> (Inner Exception #1) System.NullReferenceException: Object reference not set to an instance of an object.", "---> (Inner Exception #1) System.NullReferenceException: Object reference not set to an instance of an object.",
" at async Task Demystify.AggregateException.Throw2()", " at async Task Ben.Demystifier.Test.AggregateException.Throw2()",
" at async void Demystify.AggregateException.DemystifiesAggregateExceptions()+(?) => { }", " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }",
"---> (Inner Exception #2) System.InvalidOperationException: Operation is not valid due to the current state of the object.", "---> (Inner Exception #2) System.InvalidOperationException: Operation is not valid due to the current state of the object.",
" at async Task Demystify.AggregateException.Throw3()", " at async Task Ben.Demystifier.Test.AggregateException.Throw3()",
" at async void Demystify.AggregateException.DemystifiesAggregateExceptions()+(?) => { }"}); " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }"});
Assert.Equal(expected, trace); Assert.Equal(expected, trace);
} }

View File

@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
@ -7,9 +7,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20170810-02" /> <PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.2.0" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
namespace Demystify namespace Ben.Demystifier.Test
{ {
public class DynamicCompilation public class DynamicCompilation
{ {
@ -42,7 +42,7 @@ namespace Demystify
// Remove items that vary between test runners // Remove items that vary between test runners
.Where(s => .Where(s =>
s != " at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)" && s != " at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)" &&
s != " at Task Demystify.DynamicCompilation.DoesNotPreventStackTrace()+() => { }" s != " at Task Ben.Demystifier.Test.DynamicCompilation.DoesNotPreventStackTrace()+() => { }"
) )
.ToArray(); .ToArray();
@ -50,7 +50,7 @@ namespace Demystify
new[] { new[] {
"System.ArgumentException: Message", "System.ArgumentException: Message",
" at void lambda_method(Closure)", " at void lambda_method(Closure)",
" at async Task Demystify.DynamicCompilation.DoesNotPreventStackTrace()"}, " at async Task Ben.Demystifier.Test.DynamicCompilation.DoesNotPreventStackTrace()"},
trace); trace);
} }

View File

@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
namespace Demystify namespace Ben.Demystifier.Test
{ {
public class MixedStack public class MixedStack
{ {
@ -57,16 +57,16 @@ namespace Demystify
static List<string> ExpectedCallStack = new List<string>() static List<string> ExpectedCallStack = new List<string>()
{ {
"IEnumerable<string> Demystify.MixedStack.Iterator()+MoveNext()", "IEnumerable<string> Ben.Demystifier.Test.MixedStack.Iterator()+MoveNext()",
"string string.Join(string separator, IEnumerable<string> values)", "string string.Join(string separator, IEnumerable<string> values)",
"string Demystify.MixedStack+GenericClass<T>.GenericMethod<V>(ref V value)", "string Ben.Demystifier.Test.MixedStack+GenericClass<T>.GenericMethod<V>(ref V value)",
"async Task<string> Demystify.MixedStack.MethodAsync(int value)", "async Task<string> Ben.Demystifier.Test.MixedStack.MethodAsync(int value)",
"async Task<string> Demystify.MixedStack.MethodAsync<TValue>(TValue value)", "async Task<string> Ben.Demystifier.Test.MixedStack.MethodAsync<TValue>(TValue value)",
"(string val, bool) Demystify.MixedStack.Method(string value)", "(string val, bool) Ben.Demystifier.Test.MixedStack.Method(string value)",
"ref string Demystify.MixedStack.RefMethod(string value)", "ref string Ben.Demystifier.Test.MixedStack.RefMethod(string value)",
"(string val, bool) Demystify.MixedStack.s_func(string s, bool b)", "(string val, bool) Ben.Demystifier.Test.MixedStack.s_func(string s, bool b)",
"void Demystify.MixedStack.s_action(string s, bool b)", "void Ben.Demystifier.Test.MixedStack.s_action(string s, bool b)",
"void Demystify.MixedStack.Start((string val, bool) param)" "void Ben.Demystifier.Test.MixedStack.Start((string val, bool) param)"
}; };

View File

@ -5,7 +5,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
namespace Demystify namespace Ben.Demystifier.Test
{ {
public class NonThrownException public class NonThrownException
{ {
@ -34,8 +34,8 @@ namespace Demystify
Assert.Equal( Assert.Equal(
new[] { new[] {
"System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.", "System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.",
" at Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()+() => { }", " at Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()+() => { }",
" at async Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()", " at async Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()",
" --- End of inner exception stack trace ---"}, " --- End of inner exception stack trace ---"},
trace); trace);
@ -57,10 +57,10 @@ namespace Demystify
Assert.Equal( Assert.Equal(
new[] { new[] {
"System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.", "System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.",
" at Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()+() => { }", " at Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()+() => { }",
" at async Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()", " at async Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()",
" --- End of inner exception stack trace ---", " --- End of inner exception stack trace ---",
" at async Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()" " at async Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()"
}, },
trace); trace);
} }