Example #1
0
		public void Initialize()
		{
			MethodInfo method = GetRowTestMethodWith2Rows();
			object[] arguments = new object[] { 4, 5 };
			
			RowTestCase testCase = new RowTestCase(method, null, arguments);
			
			Assert.That(testCase.Arguments, Is.SameAs(arguments));
			Assert.That(testCase.Method, Is.SameAs(method));
			Assert.That(testCase.FixtureType, Is.SameAs(typeof (TestClass)));
		}
Example #2
0
        public void Initialize()
        {
            MethodInfo method = GetRowTestMethodWith2Rows();

            object[] arguments = new object[] { 4, 5 };

            RowTestCase testCase = new RowTestCase(method, null, arguments);

            Assert.That(testCase.Arguments, Is.SameAs(arguments));
            Assert.That(testCase.Method, Is.SameAs(method));
            Assert.That(testCase.FixtureType, Is.SameAs(typeof(TestClass)));
        }
Example #3
0
		public void Initialize_TestNameIsMethodName()
		{
			MethodInfo method = GetRowTestMethodWith2Rows();
			object[] arguments = new object[] { 4, 5 };
			
			RowTestCase testCase = new RowTestCase(method, null, arguments);

			string expectedTestName = Method_RowTestMethodWith2Rows + "(4, 5)";
			string expectedFullTestName = typeof(TestClass).FullName + "." + expectedTestName;
			Assert.That(testCase.TestName.Name, Is.EqualTo(expectedTestName));
			Assert.That(testCase.TestName.FullName, Is.EqualTo(expectedFullTestName));
		}
        public void RunTestMethod_WithNullArgument()
        {
            object[]       arguments   = new object[] { null };
            TestClass      testFixture = new TestClass();
            RowTestCase    testCase    = CreateRowTestCase(testFixture, Method_RowTestMethodWithNullArgument, arguments);
            TestCaseResult result      = new TestCaseResult(testCase.TestName.Name);

            testCase.RunTestMethod(result);

            Assert.That(testFixture.Arguments, Is.Not.Null);
            Assert.That(testFixture.Arguments[0], Is.Null);
        }
        public void RunTestMethod_WithArguments()
        {
            object[]       arguments   = new object[] { 42, 53 };
            TestClass      testFixture = new TestClass();
            RowTestCase    testCase    = CreateRowTestCase(testFixture, Method_RowTestMethodWith2Rows, arguments);
            TestCaseResult result      = new TestCaseResult(testCase.TestName.Name);

            testCase.RunTestMethod(result);

            Assert.That(testFixture.Arguments, Is.Not.Null);
            Assert.That(testFixture.Arguments[0], Is.EqualTo(arguments[0]));
            Assert.That(testFixture.Arguments[1], Is.EqualTo(arguments[1]));
        }
Example #6
0
        public void Initialize_TestNameIsMethodName()
        {
            MethodInfo method = GetRowTestMethodWith2Rows();

            object[] arguments = new object[] { 4, 5 };

            RowTestCase testCase = new RowTestCase(method, null, arguments);

            string expectedTestName     = Method_RowTestMethodWith2Rows + "(4, 5)";
            string expectedFullTestName = typeof(TestClass).FullName + "." + expectedTestName;

            Assert.That(testCase.TestName.Name, Is.EqualTo(expectedTestName));
            Assert.That(testCase.TestName.FullName, Is.EqualTo(expectedFullTestName));
        }
        public void BuildFrom_WithNull()
        {
            RowTestAddIn addIn  = new RowTestAddIn();
            MethodInfo   method = GetTestClassMethod("RowTestMethodWithNullArgument");

            Test test = addIn.BuildFrom(method);

            Assert.That(test, Is.InstanceOfType(typeof(RowTestSuite)));
            RowTestSuite suite = (RowTestSuite)test;

            Assert.That(suite.TestCount, Is.EqualTo(1));
            Assert.That(suite.Tests[0], Is.InstanceOfType(typeof(RowTestCase)));

            RowTestCase testCase = (RowTestCase)suite.Tests[0];

            Assert.That(testCase.Arguments, Is.Null);
        }
        public void BuildFrom_WithTestName()
        {
            RowTestAddIn addIn  = new RowTestAddIn();
            MethodInfo   method = GetRowTestMethodWithTestName();

            Test test = addIn.BuildFrom(method);

            Assert.That(test, Is.InstanceOfType(typeof(RowTestSuite)));
            RowTestSuite suite = (RowTestSuite)test;

            Assert.That(suite.TestCount, Is.EqualTo(1));
            Assert.That(suite.Tests[0], Is.InstanceOfType(typeof(RowTestCase)));

            RowTestCase testCase = (RowTestCase)suite.Tests[0];

            Assert.That(testCase.TestName.Name, Is.EqualTo("UnitTest(4, 5)"));
        }
Example #9
0
        public void RunTestMethod_WithNormalAndNullArguments()
        {
            object[]    arguments   = new object[] { 42, null };
            TestClass   testFixture = new TestClass();
            RowTestCase testCase    = CreateRowTestCase(testFixture, Method_RowTestMethodWithNormalAndNullArgument, arguments);

#if NUNIT_2_5
            TestResult result = new TestResult(testCase);
#else
            TestCaseResult result = new TestCaseResult(testCase.TestName.Name);
#endif

            testCase.RunTestMethod(result);

            Assert.That(testFixture.Arguments, Is.Not.Null);
            Assert.That(testFixture.Arguments[0], Is.EqualTo(arguments[0]));
            Assert.That(testFixture.Arguments[1], Is.Null);
        }
        public void BuildFrom_WithExpectedException()
        {
            RowTestAddIn addIn  = new RowTestAddIn();
            MethodInfo   method = GetRowTestMethodWithExpectedException();

            Test test = addIn.BuildFrom(method);

            Assert.That(test, Is.InstanceOfType(typeof(RowTestSuite)));
            RowTestSuite suite = (RowTestSuite)test;

            Assert.That(suite.TestCount, Is.EqualTo(1));
            Assert.That(suite.Tests[0], Is.InstanceOfType(typeof(RowTestCase)));

            RowTestCase testCase = (RowTestCase)suite.Tests[0];

            Assert.That(testCase.ExceptionExpected, Is.True);
            Assert.That(testCase.ExpectedExceptionType, Is.EqualTo(typeof(InvalidOperationException)));
        }
Example #11
0
        private RowTestCase CreateRowTestCase(TestClass fixture, string methodName, params object[] arguments)
        {
            MethodInfo method = GetTestClassMethod(methodName);

            NUnitTestFixture nunitTestFixture = new NUnitTestFixture(fixture.GetType());

            nunitTestFixture.Fixture = fixture;

            TestSuite suite = new TestSuite(nunitTestFixture.TestName.Name, method.Name);

            suite.Parent  = nunitTestFixture;
            suite.Fixture = fixture;

            RowTestCase testCase = new RowTestCase(method, method.Name, arguments);

            testCase.Fixture = fixture;
            suite.Add(testCase);

            return(testCase);
        }
        public void BuildFrom_WithRows()
        {
            RowTestAddIn addIn  = new RowTestAddIn();
            MethodInfo   method = GetRowTestMethodWith2Rows();

            Test test = addIn.BuildFrom(method);

            Assert.That(test, Is.InstanceOfType(typeof(RowTestSuite)));
            RowTestSuite suite = (RowTestSuite)test;

            Assert.That(suite.TestCount, Is.EqualTo(2));
            Assert.That(suite.Tests[0], Is.InstanceOfType(typeof(RowTestCase)));
            Assert.That(suite.Tests[1], Is.InstanceOfType(typeof(RowTestCase)));

            RowTestCase testCase1 = (RowTestCase)suite.Tests[0];
            RowTestCase testCase2 = (RowTestCase)suite.Tests[1];

            Assert.That(testCase1.Arguments.Length, Is.EqualTo(2));
            Assert.That(testCase2.Arguments.Length, Is.EqualTo(2));
        }
Example #13
0
		private RowTestCase CreateRowTestCase(TestClass fixture, string methodName, params object[] arguments)
		{
			MethodInfo method = GetTestClassMethod(methodName);
			
			NUnitTestFixture nunitTestFixture = new NUnitTestFixture(fixture.GetType());
			nunitTestFixture.Fixture = fixture;
			
			TestSuite suite = new TestSuite(nunitTestFixture.TestName.Name, method.Name);
			suite.Parent = nunitTestFixture;
			suite.Fixture = fixture;

			RowTestCase testCase = new RowTestCase(method, method.Name, arguments);
			testCase.Fixture = fixture;
			suite.Add(testCase);
			
			return testCase;
		}