-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: dotnet 5 & 6 code cleanup
- Loading branch information
Showing
4 changed files
with
96 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,94 @@ | ||
using System; | ||
using Xunit; | ||
using System; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Xunit.Extensions.AssemblyFixture; | ||
|
||
[assembly: TestFramework(AssemblyFixtureFramework.TypeName, AssemblyFixtureFramework.AssemblyName)] | ||
namespace AssemblyFixture.Tests | ||
{ | ||
public class Sample1 : IAssemblyFixture<MyAssemblyFixture> | ||
{ | ||
MyAssemblyFixture fixture; | ||
|
||
// Fixtures are injectable into the test classes, just like with class and collection fixtures | ||
public Sample1(MyAssemblyFixture fixture) | ||
{ | ||
this.fixture = fixture; | ||
} | ||
|
||
[Fact] | ||
public void EnsureSingleton() | ||
{ | ||
Assert.Equal(1, MyAssemblyFixture.InstantiationCount); | ||
} | ||
} | ||
|
||
public class Sample2 : IAssemblyFixture<MyAssemblyFixture> | ||
{ | ||
MyAssemblyFixture fixture; | ||
|
||
public Sample2(MyAssemblyFixture fixture) | ||
{ | ||
this.fixture = fixture; | ||
} | ||
|
||
[Fact] | ||
public void EnsureSingleton() | ||
{ | ||
Assert.Equal(1, MyAssemblyFixture.InstantiationCount); | ||
} | ||
} | ||
|
||
public class Sample3 : IAssemblyFixture<MyAssemblyFixtureWithMessageSink> | ||
{ | ||
MyAssemblyFixtureWithMessageSink fixture; | ||
|
||
public Sample3(MyAssemblyFixtureWithMessageSink fixture) | ||
{ | ||
this.fixture = fixture; | ||
} | ||
|
||
[Fact] | ||
public void EnsureThatHaveIMessageSink() | ||
{ | ||
Assert.NotNull(fixture.MessageSink); | ||
} | ||
} | ||
|
||
public class MyAssemblyFixture : IDisposable | ||
{ | ||
public static int InstantiationCount; | ||
|
||
public MyAssemblyFixture() | ||
{ | ||
InstantiationCount++; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
// Uncomment this and it will surface as an assembly cleanup failure | ||
//throw new DivideByZeroException(); | ||
//InstantiationCount = 0; | ||
} | ||
} | ||
|
||
public class MyAssemblyFixtureWithMessageSink : IDisposable | ||
{ | ||
public static int InstantiationCount; | ||
private IMessageSink _messageSink; | ||
|
||
public IMessageSink MessageSink => _messageSink; | ||
|
||
public MyAssemblyFixtureWithMessageSink(IMessageSink messageSink) | ||
{ | ||
_messageSink = messageSink; | ||
InstantiationCount++; | ||
} | ||
|
||
public void Dispose() | ||
using Xunit.Extensions.AssemblyFixture; | ||
|
||
[assembly: TestFramework(AssemblyFixtureFramework.TypeName, AssemblyFixtureFramework.AssemblyName)] | ||
namespace AssemblyFixture.Tests | ||
{ | ||
public class Sample1 : IAssemblyFixture<MyAssemblyFixture> | ||
{ | ||
private readonly MyAssemblyFixture _fixture; | ||
|
||
// Fixtures are injectable into the test classes, just like with class and collection fixtures | ||
public Sample1(MyAssemblyFixture fixture) | ||
{ | ||
_fixture = fixture; | ||
} | ||
|
||
[Fact] | ||
public void EnsureSingleton() | ||
{ | ||
Assert.Equal(1, MyAssemblyFixture.InstantiationCount); | ||
} | ||
} | ||
|
||
public class Sample2 : IAssemblyFixture<MyAssemblyFixture> | ||
{ | ||
private readonly MyAssemblyFixture _fixture; | ||
|
||
public Sample2(MyAssemblyFixture fixture) | ||
{ | ||
_fixture = fixture; | ||
} | ||
|
||
[Fact] | ||
public void EnsureSingleton() | ||
{ | ||
Assert.Equal(1, MyAssemblyFixture.InstantiationCount); | ||
} | ||
} | ||
|
||
public class Sample3 : IAssemblyFixture<MyAssemblyFixtureWithMessageSink> | ||
{ | ||
private readonly MyAssemblyFixtureWithMessageSink _fixture; | ||
|
||
public Sample3(MyAssemblyFixtureWithMessageSink fixture) | ||
{ | ||
_fixture = fixture; | ||
} | ||
|
||
[Fact] | ||
public void EnsureThatHaveIMessageSink() | ||
{ | ||
Assert.NotNull(_fixture.MessageSink); | ||
} | ||
} | ||
|
||
public class MyAssemblyFixture : IDisposable | ||
{ | ||
public static int InstantiationCount; | ||
|
||
public MyAssemblyFixture() | ||
{ | ||
InstantiationCount++; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
// Uncomment this and it will surface as an assembly cleanup failure | ||
//throw new DivideByZeroException(); | ||
//InstantiationCount = 0; | ||
} | ||
} | ||
|
||
public class MyAssemblyFixtureWithMessageSink : IDisposable | ||
{ | ||
public static int InstantiationCount; | ||
|
||
public IMessageSink MessageSink { get; } | ||
|
||
public MyAssemblyFixtureWithMessageSink(IMessageSink messageSink) | ||
{ | ||
MessageSink = messageSink; | ||
InstantiationCount++; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
// Uncomment this and it will surface as an assembly cleanup failure | ||
//throw new DivideByZeroException(); | ||
//InstantiationCount = 0; | ||
} | ||
} | ||
} | ||
} | ||
} |