Ejemplo n.º 1
0
 public void NullExceptionTest()
 {
     ConstructorInfo method = GetType().GetConstructor(Type.EmptyTypes);
     Assert.Throws<ArgumentNullException>(
         () => { var exceptTest = new ExceptionThrowingTest(new TimeSpan(), method, null); }
         );
 }
Ejemplo n.º 2
0
        public void ExceptionTest()
        {
            ConstructorInfo method = GetType().GetConstructor(Type.EmptyTypes);
            var e = new ArgumentNullException();
            var t = new TimeSpan();
            var exceptTest = new ExceptionThrowingTest(t, method, e);

            Assert.That(exceptTest.Exception, Is.SameAs(e));
            Assert.That(exceptTest.Method, Is.SameAs(method));
            Assert.That(exceptTest.RunningTime, Is.EqualTo(t));
        }
Ejemplo n.º 3
0
        private String GetExceptionThrowingMethodTestCode(ExceptionThrowingTest exceptionThrowingTest)
        {
            StringBuilder testCode = new StringBuilder();

            testCode.Append(TestSuiteGenerator.INDENT);
            testCode.AppendFormat("Assert.Throws<{0}>(()=>", exceptionThrowingTest.Exception.GetType().Name);
            testCode.AppendLine();
            testCode.Append(TestSuiteGenerator.INDENT);
            testCode.AppendLine("{");
            testCode.Append(TestSuiteGenerator.INDENT + TestSuiteGenerator.INDENT);
            testCode.AppendLine(GetInvokeMethodCode(exceptionThrowingTest.Method, exceptionThrowingTest.Instance, exceptionThrowingTest.Arguments).Replace(";\r\n", ";\r\n"+ TestSuiteGenerator.INDENT + TestSuiteGenerator.INDENT));
            testCode.Append(TestSuiteGenerator.INDENT);
            testCode.AppendLine("});");

            return testCode.ToString();
        }
        public void Setup()
        {
            m_TestCodeWriter = new NUnitUnitTestCodeWriter();
            m_TestType = typeof(BasicTestType);
            m_TestTypeDefaultConstructor = m_TestType.GetConstructor(Type.EmptyTypes);
            m_TestTypeInstance = new ObjectInstance(new BasicTestType(), new ObjectCreationData(m_TestTypeDefaultConstructor));
            m_ExceptionThrowingTest = new ExceptionThrowingTest(TimeSpan.FromMilliseconds(1), m_TestType.GetMethod("ExceptionThrower"), new ArgumentOutOfRangeException(), m_TestTypeInstance);

            m_ConstructorTest = new ConstructorTest(TimeSpan.FromMilliseconds(1), m_TestTypeDefaultConstructor, new BasicTestType());

            m_MethodTest = new MethodTest(TimeSpan.FromMilliseconds(1), m_TestType.GetMethod("Method1"), 5, instance:m_TestTypeInstance);
        }