Пример #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");
        }
Пример #2
0
 public void AssertIsNotNull_SpecifyValidData_Valid()
 {
     ContractAssert.IsNotNull(new object());
 }
Пример #3
0
 public void AssertIsNotNull_SpecifyNull_ThrowsAsertionException()
 {
     ContractAssert.IsNotNull(null);
 }