Esempio n. 1
0
        public void AssertsValues_SpecifyInvalidData_ThrowsAsertionException()
        {
            var catchCounter = 0;

            try { ContractAssert.IsNull(new object(), "Some message"); }
            catch (ContractException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("---");
                catchCounter++;
            }

            try { ContractAssert.IsNotNull(null, "Some message"); }
            catch (ContractException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("---");
                catchCounter++;
            }

            try { ContractAssert.IsTrue(false, "Some message"); }
            catch (ContractException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("---");
                catchCounter++;
            }

            try { ContractAssert.IsFalse(true, "Some message"); }
            catch (ContractException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("---");
                catchCounter++;
            }

            try { ContractAssert.Fail("Test error message for assertion."); }
            catch (ContractException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("---");
                catchCounter++;
            }
            try { ContractAssert.OfType <DateTime>(new object()); }
            catch (ContractException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("---");
                catchCounter++;
            }

            NUnitAssert.AreEqual(catchCounter, 6, "All the assertion should throw exception");
        }
Esempio n. 2
0
 public void AssertIsTrue_SpecifyValidData_Valid()
 {
     ContractAssert.IsTrue(true);
 }
Esempio n. 3
0
 public void AssertIsTrue_SpecifyInvalidData_ThrowsAsertionException()
 {
     ContractAssert.IsTrue(false);
 }