Esempio n. 1
0
        public void Test_ShouldHaveDefault_WithLambda_WithSpecifiedValue_WhenNotHasDefault_ShouldAssertFalse()
        {
            //---------------Set up test pack-------------------
            IClassDef    classDef                 = SetupClassDefWithAddProperty <BOFakeWithDefault>();
            const string propName                 = "NonDefaultProp";
            IPropDef     propDef                  = classDef.GetPropDef(propName);
            const string defaultValueString       = "SomeOtherValue";
            BOTester <BOFakeWithDefault> boTester = CreateGenericTester <BOFakeWithDefault>();

            //---------------Assert Precondition----------------
            Assert.IsNullOrEmpty(propDef.DefaultValueString);
            Assert.AreNotEqual(defaultValueString, propDef.DefaultValueString);
            //---------------Test Result -----------------------
            try
            {
                boTester.ShouldHaveDefault(bo => bo.NonDefaultProp, defaultValueString);
                Assert.Fail("Expected to throw an AssertionException");
            }
            //---------------Test Result -----------------------
            catch (AssertionException ex)
            {
                string expected = string.Format("The Property '{0}' for class '{1}' should have a default but does not", propName, "BOFakeWithDefault");
                StringAssert.Contains(expected, ex.Message);
            }
        }
Esempio n. 2
0
        public void Test_ShouldHaveDefault_WithLambda_WhenHasDefault_ShouldAssertTrue()
        {
            //---------------Set up test pack-------------------
            SetupClassDef <BOFakeWithDefault>();
            BOTester <BOFakeWithDefault> boTester = CreateGenericTester <BOFakeWithDefault>();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            boTester.ShouldHaveDefault(bo => bo.DefaultProp);
            //---------------Test Result -----------------------
            Assert.IsTrue(true, "If it has got here then passed");
        }
Esempio n. 3
0
        public void Test_ShouldHaveDefault_WithLambda_WithSpecifiedValue_WhenHasDefault_ShouldAssertTrue()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = SetupClassDef <BOFakeWithDefault>();
            BOTester <BOFakeWithDefault> boTester = CreateGenericTester <BOFakeWithDefault>();
            const string propName           = "DefaultProp";
            const string defaultValueString = "SomeValue";
            IPropDef     propDef            = classDef.GetPropDef(propName);

            //---------------Assert Precondition----------------
            Assert.IsNotNullOrEmpty(propDef.DefaultValueString);
            Assert.AreEqual(defaultValueString, propDef.DefaultValueString);
            //---------------Execute Test ----------------------
            boTester.ShouldHaveDefault(bo => bo.DefaultProp, defaultValueString);
            //---------------Test Result -----------------------
            Assert.IsTrue(true, "If it has got here then passed");
        }