コード例 #1
0
        public void TestTestThrowsArgumentExceptionWhenTestNameIsNullOrEmpty(
            [Values] bool isNull)
        {
            string       name   = isNull ? null : string.Empty;
            const string value  = "Value_1";
            const string xmlTag = "parent_1";
            XmlSerializableElementForTest parent =
                new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test);

            INUnitFilterContainerElementInternal element =
                new NUnitFilterContainerElement(parent, NUnitElementType.And);

            Assert.Throws(
                Is.TypeOf <ArgumentException>().And.Message
                .EqualTo("The name cannot be null or empty. (Parameter 'name')"), () =>
            {
                // ReSharper disable once UnusedVariable
                INUnitFilterElement test = element.Test(name);
            });
        }
コード例 #2
0
        public void TestTestSetsChildAndReturnsNewAndElementWithParent(
            [Values] bool isRegularExpression)
        {
            const string name   = "name_1";
            const string value  = "Value_1";
            const string xmlTag = "parent_1";
            XmlSerializableElementForTest parent =
                new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test);

            INUnitFilterContainerElementInternal element =
                new NUnitFilterContainerElement(parent, NUnitElementType.And);

            INUnitFilterElementInternal test = (INUnitFilterElementInternal)element.Test(name, isRegularExpression);

            Assert.IsNotNull(test);
            Assert.AreEqual(NUnitElementType.Test, test.ElementType);
            Assert.AreSame(element, test.Parent);
            Assert.AreSame(test, element.Child);
            Assert.AreEqual(name, test.ElementName);
            Assert.IsNull(test.ElementValue);
            Assert.AreEqual(isRegularExpression, test.IsRegularExpression);
        }