Last active
December 25, 2015 01:39
-
-
Save madstt/6896190 to your computer and use it in GitHub Desktop.
Combining ExpectedException and AutoData NUnit Addin in the same test assembly
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
[NUnitAddin] | |
public class ClassWithAddin : Ploeh.AutoFixture.NUnit2.Addins.Addin | |
{ | |
protected IFixture Fixture; | |
protected void Setup() | |
{ | |
Fixture = new Fixture(); | |
} | |
} |
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
public class SystemUnderTest | |
{ | |
public void MethodThatThrowsException() | |
{ | |
throws new ArgumentNullException(); | |
} | |
public string Property {get; set;} | |
} |
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
[TestFixture] | |
public class TestFixture | |
{ | |
[SetUp] | |
public new void Setup() | |
{ | |
base.Setup(); | |
Fixture.Customize<SystemUnderTest>(x => x.Without(system => system.Property)); | |
} | |
[Test, AutoData] | |
public void WhateverTestName(SystemUnderTest sut) | |
{ | |
//Arrange | |
//Act | |
//Assert | |
Assert.Throws<ArgumentNullException>(() => sut.MethodThatThrowsException()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment