My favorites | Sign in
Project Logo
                
Show all Featured wiki pages:
SyntaxOverview
Links:
Blogs:
Feeds:
People details
Project owners:
  fabiomaulo
Project committers:
simone.busoli

IMPORTANT NOTES

SharpTestsEx is and will be the multi-purpose version of NUnitEx. You can use SharpTestsEx with NUnit, xUnit, MsTests , MbUnit and, in theory, with any other test framework.

NUnitEx

Set of constraints extensions to work on-top of NUnit.

Strongly typed Assertions few examples

true.Should().Be.True();
false.Should().Be.False();

const string somethig = "something";
somethig.Should().Contain("some");
somethig.Should().Not.Contain("also");
somethig.ToUpperInvariant().Should().Not.Contain("some");

somethig.Should()
    .StartWith("so")
    .And
    .EndWith("ing")
    .And
    .Contain("meth");

somethig.Should()
    .Not.StartWith("ing")
    .And
    .Not.EndWith("so")
    .And
    .Not.Contain("body");

var ints = new[] { 1, 2, 3 };
ints.Should().Have.SameSequenceAs(new[] { 1, 2, 3 });
ints.Should().Not.Have.SameSequenceAs(new[] { 3, 2, 1 });
ints.Should().Not.Be.Null();
ints.Should().Not.Be.Empty();

ints.Should()
    .Contain(2)
    .And
    .Not.Contain(4);

(new int[0]).Should().Be.Empty();

Exceptions assertions

(new Action(() => new AClass(null)))
    .Should().Throw<ArgumentNullException>()
    .And
    .ValueOf.ParamName
        .Should().Be.EqualTo("obj");

(new Action(() => new MyClass(null))
    .Should().Throw<ArgumentException>()
    .And
    .ValueOf.InnerExceptions()
        .OfType<ArgumentOutOfRangeException>().First()
	.ParamName.Should().Be.EqualTo("obj");

new Action(() => new MyClass(null))
    .Should().Throw<ArgumentException>()
    .And
    .ValueOf.InnerExceptions().Select(e => e.GetType())
        .Should().Contain(typeof(ArgumentOutOfRangeException));

(new Action(() => new MyClass(null))
    .Should().Throw<ArgumentException>()
    .And
    .ValueOf.InnerException
        .Should().Be.OfType<ArgumentNullException>()
            .And
            .ValueOf.Message
                .Should().Be.EqualTo("Null not allowed.");








Hosted by Google Code