Beispiel #1
0
        public void Test_ShouldBeCompulsory_WhenIsNot_ShouldAssertFalse()
        {
            //---------------Set up test pack-------------------
            var SingleValueDef = GetMockSingleValueDef();

            SingleValueDef.PropertyName = GetRandomString();
            var className = GetRandomString();

            SingleValueDef.Stub(def => def.ClassName).Return(className);
            SingleValueDef.Compulsory = false;
            var tester = new SingleValueTesterTestDouble(SingleValueDef);

            //---------------Assert Precondition----------------
            Assert.IsFalse(SingleValueDef.Compulsory);
            //---------------Execute Test ----------------------
            try
            {
                tester.ShouldBeCompulsory();
                Assert.Fail("Expected to throw an AssertionException");
            }
            //---------------Test Result -----------------------
            catch (AssertionException ex)
            {
                var expected = string.Format("The Property '{0}' for class '{1}' should be compulsory",
                                             SingleValueDef.PropertyName, className);
                StringAssert.Contains(expected, ex.Message);
            }
        }
Beispiel #2
0
        public void Test_ShouldBeCompulsory_WhenIs_ShouldAssertTrue()
        {
            //---------------Set up test pack-------------------
            var SingleValueDef = GetMockSingleValueDef();

            SingleValueDef.Compulsory = true;
            var tester = new SingleValueTesterTestDouble(SingleValueDef);

            //---------------Assert Precondition----------------
            Assert.IsTrue(SingleValueDef.Compulsory);
            //---------------Execute Test ----------------------
            tester.ShouldBeCompulsory();
            //---------------Test Result -----------------------
            Assert.IsTrue(true, "If it has got here then passed");
        }