EmptyConstraint tests a whether a string or collection is empty, postponing the decision about which test is applied until the type of the actual argument is known.
Inheritance: NUnit.Framework.Constraints.Constraint
示例#1
0
 protected override void SetUp()
 {
     Matcher = new EmptyConstraint();
     GoodValues = new object[] { string.Empty, new object[0], new System.Collections.ArrayList() };
     BadValues = new object[] { "Hello", new object[] { 1, 2, 3 } };
     Description = "<empty>";
 }
示例#2
0
        public void AssertTestCase_TestCaseFailing_MessageIsAvailable()
        {
            var sut = "not empty string";
            var ctr = new EmptyConstraint();
            var xmlContent = "<test><system></system><assert></assert></test>";

            var testSuite = new TestSuite();

            try
            {
                testSuite.AssertTestCase(sut, ctr, xmlContent);
            }
            catch (AssertionException ex)
            {
                Console.WriteLine(ex.Message);
                Assert.That(ex.Message, Is.StringContaining("empty"));
            }
            catch (Exception ex)
            {
                Assert.Fail("The exception should have been an AssertionException but was {0}.", new object[] { ex.GetType().FullName });
            }
        }
示例#3
0
 public void SetUp()
 {
     TheConstraint        = new EmptyConstraint();
     ExpectedDescription  = "<empty>";
     StringRepresentation = "<empty>";
 }
示例#4
0
 public void SetUp()
 {
     theConstraint = new EmptyConstraint();
     expectedDescription = "<empty>";
     stringRepresentation = "<empty>";
 }
示例#5
0
        public void AssertTestCase_TestCaseFailing_StackTraceIsFilledWithXml()
        {
            var sut = "not empty";
            var ctr = new EmptyConstraint();
            var xmlContent = "<test><system></system><assert></assert></test>";

            var testSuite = new TestSuite();

            try
            {
                testSuite.AssertTestCase(sut, ctr, xmlContent);
            }
            catch (AssertionException ex)
            {
                Assert.That(ex.StackTrace, Is.EqualTo(xmlContent));
            }
            catch (Exception ex)
            {
                Assert.Fail("The exception should have been an AssertionException but was {0}.", new object[] { ex.GetType().FullName });
            }
        }