Ejemplo 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");
        }
Ejemplo n.º 2
0
 public void AssertIsTrue_SpecifyInvalidData_ThrowsAsertionException()
 {
     ContractAssert.IsTrue(false);
 }
Ejemplo n.º 3
0
 public void AssertIsTrue_SpecifyValidData_Valid()
 {
     ContractAssert.IsTrue(true);
 }
Ejemplo n.º 4
0
 public void AssertIsNull_SpecifyValidData_Valid()
 {
     ContractAssert.IsNull(null);
 }
Ejemplo n.º 5
0
 public void AssertIsNotNull_SpecifyValidData_Valid()
 {
     ContractAssert.IsNotNull(new object());
 }
Ejemplo n.º 6
0
 public void AssertIsNotNull_SpecifyNull_ThrowsAsertionException()
 {
     ContractAssert.IsNotNull(null);
 }
Ejemplo n.º 7
0
 public void AssertIsNotNull_SpecifyInvalidData_ThrowsAsertionException()
 {
     ContractAssert.IsNull(new object());
 }
Ejemplo n.º 8
0
 public void AssertBoolean_SpecifyValidData_Valid()
 {
     ContractAssert.IsFalse(false);
 }