Skip to content

Instantly share code, notes, and snippets.

@madstt
Last active December 25, 2015 01:39
Show Gist options
  • Save madstt/6896190 to your computer and use it in GitHub Desktop.
Save madstt/6896190 to your computer and use it in GitHub Desktop.
Combining ExpectedException and AutoData NUnit Addin in the same test assembly
[NUnitAddin]
public class ClassWithAddin : Ploeh.AutoFixture.NUnit2.Addins.Addin
{
protected IFixture Fixture;
protected void Setup()
{
Fixture = new Fixture();
}
}
public class SystemUnderTest
{
public void MethodThatThrowsException()
{
throws new ArgumentNullException();
}
public string Property {get; set;}
}
[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