Пример #1
0
        /// <summary>
        ///     Check common NUnitSuite constructor properties.
        /// </summary>
        /// <param name="suite">The NUnitSuite to check.</param>
        /// <param name="argsEmpty">If the argument list is considered empty</param>
        private static void TestCommonConstructorProperties(NUnitSuite suite, bool argsEmpty = true)
        {
            Assert.IsNotNull(suite.Id);
            Assert.IsNotEmpty(suite.Id);
            Assert.IsNull(suite.MethodName);
            Assert.IsNull(suite.Method);
            Assert.IsNotNull(suite.Arguments);
            if (argsEmpty)
            {
                CollectionAssert.IsEmpty(suite.Arguments);
            }

            Assert.AreEqual(RunState.Runnable, suite.RunState);
            Assert.AreEqual(c_SuiteXmlElement, suite.XmlElementName);
            Assert.AreEqual(suite.GetType().Name, suite.TestType);
            Assert.AreEqual(0, suite.TestCaseCount);
            Assert.IsNotNull(suite.Properties);
            CollectionAssert.IsEmpty(suite.Properties.Keys);
            Assert.IsTrue(suite.IsSuite);
            Assert.IsFalse(suite.HasChildren);
            Assert.IsNull(suite.Parent);
            Assert.IsNotNull(suite.Tests);
            CollectionAssert.IsEmpty(suite.Tests);
            Assert.IsNotNull(suite.SetUpMethods);
            CollectionAssert.IsEmpty(suite.SetUpMethods);
            Assert.IsNotNull(suite.TearDownMethods);
            CollectionAssert.IsEmpty(suite.TearDownMethods);
        }
Пример #2
0
        public void TestConstructorWithTestSuiteAndFilter([Values] bool withChildTests, [Values] bool withFilter)
        {
            ITestFilter filter = withFilter
                ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter
                : NUnitFilter.Empty;

            NUnitSuite suiteInitial = new NUnitSuite("suite-one");

            if (withChildTests)
            {
                suiteInitial.Add(typeof(TestFixtureStubOne).Assembly);
            }

            NUnitSuite suite = new NUnitSuite(suiteInitial, filter);

            Assert.AreEqual(suiteInitial.Name, suite.Name);
            Assert.AreEqual(suiteInitial.FullName, suite.FullName);
            Assert.IsNull(suite.ClassName);
            Assert.IsNull(suite.TypeInfo);
            Assert.IsNotNull(suite.Id);
            Assert.IsNotEmpty(suite.Id);
            Assert.IsNull(suite.MethodName);
            Assert.IsNull(suite.Method);
            Assert.IsNull(suite.Arguments);
            Assert.AreEqual(RunState.Runnable, suite.RunState);
            Assert.AreEqual(c_SuiteXmlElement, suite.XmlElementName);
            Assert.AreEqual(suite.GetType().Name, suite.TestType);
            Assert.IsNotNull(suite.Properties);
            CollectionAssert.IsEmpty(suite.Properties.Keys);
            Assert.IsTrue(suite.IsSuite);
            Assert.IsNull(suite.Parent);
            Assert.IsNotNull(suite.Tests);
            if (withChildTests)
            {
                int testCount = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount;
                Assert.AreEqual(testCount, suite.TestCaseCount);
                Assert.IsTrue(suite.HasChildren);
                CollectionAssert.IsNotEmpty(suite.Tests);
            }
            else
            {
                Assert.AreEqual(0, suite.TestCaseCount);
                Assert.IsFalse(suite.HasChildren);
                CollectionAssert.IsEmpty(suite.Tests);
            }

            Assert.IsNotNull(suite.SetUpMethods);
            CollectionAssert.IsEmpty(suite.SetUpMethods);
            Assert.IsNotNull(suite.TearDownMethods);
            CollectionAssert.IsEmpty(suite.TearDownMethods);
        }