Skip to content

Commit

Permalink
Xunit hack (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Sep 3, 2018
1 parent 509853b commit c2042c5
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 97 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Auto detect text files and perform LF normalization
* text

# Don't check these into the repo as LF to work around TeamCity bug
*.xml -text
*.targets -text
*.approved.txt -text


# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
Expand All @@ -21,4 +21,4 @@
*.ico binary
*.snk binary
*.pdb binary
*.svg binary
*.svg binary
4 changes: 2 additions & 2 deletions Tests/ApprovedTests.SpecialClass_release.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
.override [mscorlib]System.Collections.IEnumerator::MoveNext
// Code size 92 (0x5c)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
.locals init ([0] int32 V_0,
[1] int32 V_1)
IL_0000: ldarg.0
IL_0001: ldfld int32 SpecialClass/'<CountTo>d__0'::'<>1__state'
IL_0006: stloc.0
Expand Down
3 changes: 2 additions & 1 deletion Tests/ApprovedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Xunit;
using System.Linq;

public class ApprovedTests
public class ApprovedTests:TestBase
{
[Fact]
public void ClassWithBadAttributes()
Expand Down Expand Up @@ -129,4 +129,5 @@ public void ErrorsList()
ObjectApprover.VerifyWithJson(AssemblyWeaver.TestResult.Errors.Select(x=>x.Text));
}
}

#endif
9 changes: 0 additions & 9 deletions Tests/AssemblyWeaver.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System.Collections.Generic;
using System.Reflection;
using System.Xml.Linq;
#if (NET472)
using ApprovalTests.Core;
using ApprovalTests.Reporters;
#endif
using Fody;
#pragma warning disable 618

Expand All @@ -14,11 +10,6 @@ public static class AssemblyWeaver

static AssemblyWeaver()
{
#if (NET472)
//TODO: this works around https://github.com/approvals/ApprovalTests.Net/issues/159
var reporters = (IEnvironmentAwareReporter[])FrameworkAssertReporter.INSTANCE.Reporters;
reporters[2] = XUnit2Reporter.INSTANCE;
#endif
var weavingTask = new ModuleWeaver
{
Config = new XElement("NullGuard",
Expand Down
2 changes: 1 addition & 1 deletion Tests/RewritingGenerics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void GenericClassThrowsOnNullReferenceType(string className)
var messages = exceptions.Select(ex => ex.Message.Replace(Environment.NewLine, "|"));
var signature = string.Join(Environment.NewLine, messages).Replace(className, "ClassName");

Assert.Equal(expected, signature);
Assert.Equal(expected.Replace("\r\n","\n"), signature.Replace("\r\n", "\n"));
}

[Fact]
Expand Down
16 changes: 16 additions & 0 deletions Tests/TestBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#if (NET472)
using ApprovalTests.Core;
using ApprovalTests.Reporters;
#endif

public class TestBase
{
static TestBase()
{
#if (NET472)
//TODO: this works around https://github.com/approvals/ApprovalTests.Net/issues/159
var reporters = (IEnvironmentAwareReporter[]) FrameworkAssertReporter.INSTANCE.Reporters;
reporters[3] = XUnit2Reporter.INSTANCE;
#endif
}
}
82 changes: 0 additions & 82 deletions TestsExplicit/ApprovedTests.ExplicitMode.approved.txt

This file was deleted.

0 comments on commit c2042c5

Please sign in to comment.