예제 #1
0
        static void NegativeTest()
        {
            var t = new TestMain(false);

            try
            {
#if NETFRAMEWORK_4_5 || NETFRAMEWORK_4_0
                try {
                    t.Run();
                }
                catch (AggregateException ae) {
                    throw ae.Flatten().InnerException;
                }
#else
                t.Run();
#endif
                throw new Exception("Expected failure did not happen");
            }
            catch (TestInfrastructure.RewriterMethods.ContractException e)
            {
                TestInfrastructure.Assert.AreEqual(t.NegativeExpectedKind, e.Kind);
                TestInfrastructure.Assert.AreEqual(t.NegativeExpectedCondition, e.Condition);
            }
            catch (ArgumentException e)
            {
                TestInfrastructure.Assert.AreEqual(t.NegativeExpectedKind, ContractFailureKind.Precondition);
                TestInfrastructure.Assert.AreEqual(t.NegativeExpectedCondition, e.Message);
            }
        }
예제 #2
0
 static void PositiveTest()
 {
     try
     {
         var t = new TestMain(true);
         t.Run();
     }
     catch
     {
         Console.WriteLine();
         Console.WriteLine("Positive test failed.");
         Console.WriteLine();
         throw;
     }
 }