public void TestBuildThrowsInvalidOperationExceptionWhenAParentAndChildReferenceAreNotEqual() { const string value = "Value_"; const string xmlTag = "name_"; NUnitFilterContainerElementForTest root = new NUnitFilterContainerElementForTest(null, NUnitElementType.RootFilter); XmlSerializableElementForTest wrongChild = new XmlSerializableElementForTest(xmlTag + 1, value + 1, NUnitElementType.Test); wrongChild.Parent = root; XmlSerializableElementForTest leafChild = new XmlSerializableElementForTest(xmlTag + 2, value + 2, NUnitElementType.Id); leafChild.Parent = root; root.SetChild(wrongChild); Assert.AreSame(root, leafChild.Parent); Assert.AreNotSame(leafChild, root.Child); const string parentString = "{NUnitFilterContainerElementForTest: {Type: RootFilter, Parent: Null, Child: {XmlSerializableElementForTest: {Type: Test}}}}"; Assert.Throws( Is.TypeOf <InvalidOperationException>().And.Message .EqualTo( $"The parent element's {parentString} child was not the same reference as the current node." + " Forward traversal will not proceed properly." + " This may indicate an error in the construction or parsing of the filter."), () => NUnitFilter.Build(leafChild)); }
public void TestToXmlStringWithParentNotNullAndElementTypeNotReturnsChildXmlStrings( [Values] bool withXmlTag) { const string valueParent = "Value_1"; const string xmlTagParent = "name_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTagParent, valueParent, NUnitElementType.Test); const string valueChild = "Value_2"; const string xmlTagChild = "name_2"; XmlSerializableElementForTest child = new XmlSerializableElementForTest(xmlTagChild, valueChild, NUnitElementType.Test); string expectedValueChild = NUnitFilterTestHelper.CreateXmlNode(xmlTagChild, valueChild); // With tag includes parent xml tag, without is just value string expected = withXmlTag ? NUnitFilterTestHelper.CreateXmlNode(NUnitFilterTestHelper.XmlNotTag, expectedValueChild) : expectedValueChild; NUnitFilterContainerElementForTest element = new NUnitFilterContainerElementForTest(parent, NUnitElementType.Not); element.SetChild(child); string actual = element.ToXmlString(withXmlTag); Assert.AreEqual(expected, actual); }
public void TestBuildThrowsInvalidOperationExceptionWhenTheRootIsNotOfTypeRootElement() { const string value = "Value_"; const string xmlTag = "name_"; XmlSerializableElementForTest root = new XmlSerializableElementForTest(xmlTag + 1, value + 1, NUnitElementType.Test); XmlSerializableElementForTest leafChild = new XmlSerializableElementForTest(xmlTag + 2, value + 2, NUnitElementType.Id); leafChild.Parent = root; root.Child = leafChild; Assert.AreNotEqual(NUnitElementType.RootFilter, root.ElementType); Assert.IsNull(root.Parent); Assert.IsNotNull(root.Child); Assert.AreSame(root, leafChild.Parent); Assert.AreSame(leafChild, root.Child); Assert.Throws( Is.TypeOf <InvalidOperationException>().And.Message .EqualTo( "The root element type was not the expected type of RootFilter but was instead Test." + " Forward traversal will not proceed properly." + " This may indicate an error in the construction or parsing of the filter."), () => NUnitFilter.Build(leafChild)); }
public void TestBuildWithOnlyANotPlusFilterElement( [ValueSource(typeof(NUnitFilterTestHelper), nameof(NUnitFilterTestHelper.GetFilterElements))] NUnitElementType elementType) { const string value = "Value_"; NUnitFilterContainerElementForTest root = new NUnitFilterContainerElementForTest(null, NUnitElementType.RootFilter); XmlSerializableElementForTest child1 = new XmlSerializableElementForTest("name", value + 1, NUnitElementType.Not); XmlSerializableElementForTest child2 = new XmlSerializableElementForTest("class", value + 2, elementType); root.SetChild(child1); child1.Parent = root; child1.Child = child2; child2.Parent = child1; // Not will skip its child element const string expected = "<filter><name>Value_1</name></filter>"; NUnitFilter filter = NUnitFilter.Build(child2); Assert.IsNotNull(filter); Assert.AreEqual(expected, filter.FilterXmlString); Assert.AreEqual(expected, GetXmlString(filter.Filter)); }
public void TestBuildWithBothAndPlusOrPlusFilterElements() { const string value = "Value_"; NUnitFilterContainerElementForTest root = new NUnitFilterContainerElementForTest(null, NUnitElementType.RootFilter); XmlSerializableElementForTest child1 = new XmlSerializableElementForTest("name", value + 1, NUnitElementType.Test); XmlSerializableElementForTest or1 = new XmlSerializableElementForTest(null, null, NUnitElementType.Or); XmlSerializableElementForTest child2 = new XmlSerializableElementForTest("class", value + 2, NUnitElementType.Test); XmlSerializableElementForTest or2 = new XmlSerializableElementForTest(null, null, NUnitElementType.Or); XmlSerializableElementForTest child3 = new XmlSerializableElementForTest("namespace", value + 3, NUnitElementType.Test); XmlSerializableElementForTest and3 = new XmlSerializableElementForTest(null, null, NUnitElementType.And); XmlSerializableElementForTest child4 = new XmlSerializableElementForTest("cat", value + 4, NUnitElementType.Test); XmlSerializableElementForTest and4 = new XmlSerializableElementForTest(null, null, NUnitElementType.And); XmlSerializableElementForTest child5 = new XmlSerializableElementForTest("method", value + 5, NUnitElementType.Test); XmlSerializableElementForTest or5 = new XmlSerializableElementForTest(null, null, NUnitElementType.Or); XmlSerializableElementForTest child6 = new XmlSerializableElementForTest("test", value + 6, NUnitElementType.Test); root.SetChild(child1); child1.Parent = root; child1.Child = or1; or1.Parent = child1; or1.Child = child2; child2.Parent = or1; child2.Child = or2; or2.Parent = child2; or2.Child = child3; child3.Parent = or2; child3.Child = and3; and3.Parent = child3; and3.Child = child4; child4.Parent = and3; child4.Child = and4; and4.Parent = child4; and4.Child = child5; child5.Parent = and4; child5.Child = or5; or5.Parent = child5; or5.Child = child6; child6.Parent = or5; const string expected = "<filter><or><name>Value_1</name><class>Value_2</class><and><namespace>Value_3</namespace><cat>Value_4</cat><method>Value_5</method></and><test>Value_6</test></or></filter>"; NUnitFilter filter = NUnitFilter.Build(child6); Assert.IsNotNull(filter); Assert.AreEqual(expected, filter.FilterXmlString); Assert.AreEqual(expected, GetXmlString(filter.Filter)); }
public void TestToStringReturnsStringRepresentation([Values] bool isChildNull, [Values] bool withValue, [Values] bool isRegularExpression) { const string name = "name_1"; const string value = "Value_"; const string xmlTag = "child_"; NUnitFilterContainerElement parent = new NUnitFilterContainerElement(null, NUnitElementType.RootFilter); XmlSerializableElementForTest child = new XmlSerializableElementForTest(xmlTag + 2, value + 2, NUnitElementType.Id); const string parentString = "{NUnitFilterContainerElement: {Type: RootFilter}}"; string childString = isChildNull ? "Null" : "{XmlSerializableElementForTest: {Type: Id}}"; string elementValue = withValue ? "Value_1" : null; string expected = $"{{NUnitFilterElementForTest: {{Type: Test, Name: \"name_1\", Value: \"{elementValue}\"," + $" IsRegularExpression: {isRegularExpression}, Parent: {parentString}, Child: {childString}}}}}"; NUnitFilterElementForTest element = new NUnitFilterElementForTest(parent, NUnitElementType.Test, name, isRegularExpression, elementValue); if (!isChildNull) { element.SetChild(child); } string actual = element.ToString(); Assert.AreEqual(expected, actual); }
public void TestBuildThrowsArgumentOutOfRangeExceptionWhenTheElementIsNotASupportedType() { const string value = "Value_"; const string xmlTag = "name_"; NUnitFilterContainerElementForTest root = new NUnitFilterContainerElementForTest(null, NUnitElementType.RootFilter); XmlSerializableElementForTest leafChild = new XmlSerializableElementForTest(xmlTag + 1, value + 1, (NUnitElementType)(-1)); leafChild.Parent = root; root.SetChild(leafChild); Assert.IsNull(root.Parent); Assert.IsNotNull(root.Child); Assert.AreSame(root, leafChild.Parent); Assert.AreSame(leafChild, root.Child); const string currentString = "{XmlSerializableElementForTest: {Type: -1, Parent: {NUnitFilterContainerElementForTest: {Type: RootFilter}}, Child: Null}}"; Assert.Throws( Is.TypeOf <ArgumentOutOfRangeException>().And.Message .EqualTo( $"The given element type is not supported. {currentString}" + $" (Parameter 'ElementType'){Environment.NewLine}Actual value was -1."), () => NUnitFilter.Build(leafChild)); }
public void TestToStringReturnsStringRepresentation([Values] bool isParentNull, [Values] bool isChildNull) { // Create expected string of xml nodes const string valueParent = "Value_1"; const string xmlTagParent = "name_1"; XmlSerializableElementForTest parent = isParentNull ? null : new XmlSerializableElementForTest(xmlTagParent, valueParent, NUnitElementType.Test); const string valueChild = "Value_2"; const string xmlTagChild = "name_2"; XmlSerializableElementForTest child = new XmlSerializableElementForTest(xmlTagChild, valueChild, NUnitElementType.Id); NUnitElementType elementType = isParentNull ? NUnitElementType.RootFilter : NUnitElementType.And; string parentString = isParentNull ? "Null" : "{XmlSerializableElementForTest: {Type: Test}}"; string childString = isChildNull ? "Null" : "{XmlSerializableElementForTest: {Type: Id}}"; string expected = $"{{NUnitFilterContainerElementForTest: {{Type: {elementType}, Parent: {parentString}, Child: {childString}}}}}"; NUnitFilterContainerElementForTest element = new NUnitFilterContainerElementForTest(parent, elementType); if (!isChildNull) { element.SetChild(child); } string actual = element.ToString(); Assert.AreEqual(expected, actual); }
public void TestConstructorWithParentNotNullAndElementTypeSupportedButNotRootFilter( NUnitElementType elementType) { const string value = "Value_1"; const string xmlTag = "name_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test); string expectedXmlTag = null; switch (elementType) { // NUnitElementType.RootFilter covered in a dedicated test case case NUnitElementType.And: expectedXmlTag = NUnitFilterTestHelper.XmlAndTag; break; case NUnitElementType.Or: expectedXmlTag = NUnitFilterTestHelper.XmlOrTag; break; default: Assert.Fail($"The type {elementType} is not supported for this test."); break; } INUnitFilterElementCollectionInternal element = new NUnitFilterElementCollection(parent, elementType); Assert.AreSame(parent, element.Parent); Assert.IsNull(element.Child); Assert.AreEqual(elementType, element.ElementType); Assert.AreEqual(expectedXmlTag, element.XmlTag); }
public void TestIdWithTestIdArraySetsChildAndReturnsNewAndElementWithParent() { const string name1 = "name_1"; const string name2 = "name_2"; const string name3 = "name_3"; string[] names = { name1, null, name2, string.Empty, name3 }; const string value = "Value_1"; const string xmlTag = "parent_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test); const string expectedName = name1 + "," + name2 + "," + name3; INUnitFilterContainerElementInternal element = new NUnitFilterContainerElement(parent, NUnitElementType.And); INUnitFilterElementInternal id = (INUnitFilterElementInternal)element.Id(names); Assert.IsNotNull(id); Assert.AreEqual(NUnitElementType.Id, id.ElementType); Assert.AreSame(element, id.Parent); Assert.AreSame(id, element.Child); Assert.AreEqual(expectedName, id.ElementName); Assert.IsNull(id.ElementValue); Assert.IsFalse(id.IsRegularExpression); }
public void TestXmlTagPropertyReturnsXmlTagProvidedWithConstructor() { const string value = "Value_1"; const string xmlTag = "name_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test); INUnitFilterContainerElementInternal element = new NUnitFilterContainerElement(parent, NUnitElementType.And); Assert.AreEqual(NUnitFilterTestHelper.XmlAndTag, element.XmlTag); }
TestConstructorThrowsArgumentExceptionWhenParentNotNullAndElementTypeRootFilter() { const string value = "Value_1"; const string xmlTag = "name_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test); Assert.Throws( Is.TypeOf <ArgumentException>().And.Message.EqualTo( "The parent element cannot be non-null if the element type is RootFilter. (Parameter 'parent')"), // ReSharper disable once ObjectCreationAsStatement () => new NUnitFilterContainerElement(parent, NUnitElementType.RootFilter)); }
public void TestChildPropertyThrowsArgumentNullExceptionWhenChildSetToNull() { const string value = "Value_1"; const string xmlTag = "name_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test); NUnitFilterContainerElementForTest element = new NUnitFilterContainerElementForTest(parent, NUnitElementType.And); Assert.Throws( Is.TypeOf <ArgumentNullException>().And.Message .EqualTo("The value cannot be null. (Parameter 'value')"), () => element.SetChild(null)); }
public void TestAddWithNonNullItemAddsItem() { // Create collection and item to add const int count = 3; const string value = "Value_new"; const string xmlTag = "name_new"; XmlSerializableElementForTest item = new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.And); ExpressionCollection <INUnitFilterBaseElement> collection = NUnitFilterTestHelper.CreateCollection(count, out _); collection.Add(item); Assert.AreEqual(count + 1, collection.Count); Assert.AreSame(item, collection.Last()); }
public void TestContainsWhenItemIsNotPresentReturnsFalse([Values] bool isNull) { // Create collection and item to search const int count = 3; const string value = "Value_new"; const string xmlTag = "name_new"; XmlSerializableElementForTest item = isNull ? null : new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.And); ExpressionCollection <INUnitFilterBaseElement> collection = NUnitFilterTestHelper.CreateCollection(count, out _); Assert.AreEqual(count, collection.Count); bool contains = collection.Contains(item); Assert.IsFalse(contains); }
TestConstructorThrowsArgumentOutOfRangeExceptionWhenElementTypeNotSupported( [ValueSource(typeof(NUnitFilterTestHelper), nameof(NUnitFilterTestHelper.GetFilterElements))] NUnitElementType elementType) { const string value = "Value_1"; const string xmlTag = "name_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test); Assert.Throws( Is.TypeOf <ArgumentOutOfRangeException>().And.Message .EqualTo( $"The given element type is not supported. (Parameter 'elementType'){Environment.NewLine}" + $"Actual value was {elementType}."), // ReSharper disable once ObjectCreationAsStatement () => new NUnitFilterContainerElement(parent, elementType)); }
public void TestNotPropertySetsChildAndReturnsNewAndElementWithParent() { const string value = "Value_1"; const string xmlTag = "name_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test); INUnitFilterElementCollectionInternal element = new NUnitFilterElementCollection(parent, NUnitElementType.And); INUnitFilterContainerElementInternal not = (INUnitFilterContainerElementInternal)element.Not; Assert.IsNotNull(not); Assert.AreEqual(NUnitElementType.Not, not.ElementType); Assert.AreSame(element, not.Parent); Assert.AreSame(not, element.Child); }
public void TestBuildWithOnlyAndPlusFilterElements() { const string value = "Value_"; NUnitFilterContainerElementForTest root = new NUnitFilterContainerElementForTest(null, NUnitElementType.RootFilter); XmlSerializableElementForTest child1 = new XmlSerializableElementForTest("name", value + 1, NUnitElementType.Test); XmlSerializableElementForTest and1 = new XmlSerializableElementForTest(null, null, NUnitElementType.And); XmlSerializableElementForTest child2 = new XmlSerializableElementForTest("class", value + 2, NUnitElementType.Test); XmlSerializableElementForTest and2 = new XmlSerializableElementForTest(null, null, NUnitElementType.And); XmlSerializableElementForTest child3 = new XmlSerializableElementForTest("namespace", value + 3, NUnitElementType.Test); XmlSerializableElementForTest and3 = new XmlSerializableElementForTest(null, null, NUnitElementType.And); XmlSerializableElementForTest child4 = new XmlSerializableElementForTest("cat", value + 4, NUnitElementType.Test); root.SetChild(child1); child1.Parent = root; child1.Child = and1; and1.Parent = child1; and1.Child = child2; child2.Parent = and1; child2.Child = and2; and2.Parent = child2; and2.Child = child3; child3.Parent = and2; child3.Child = and3; and3.Parent = child3; and3.Child = child4; child4.Parent = and3; const string expectedInner = "<name>Value_1</name><class>Value_2</class><namespace>Value_3</namespace><cat>Value_4</cat>"; string expected = $"<filter>{expectedInner}</filter>"; string expectedFilter = $"<filter><and>{expectedInner}</and></filter>"; NUnitFilter filter = NUnitFilter.Build(child4); Assert.IsNotNull(filter); Assert.AreEqual(expected, filter.FilterXmlString); Assert.AreEqual(expectedFilter, GetXmlString(filter.Filter)); }
public void TestChildPropertyReturnsSetChild() { const string value = "Value_"; const string xmlTag = "name_"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag + 1, value + 1, NUnitElementType.Test); XmlSerializableElementForTest child = new XmlSerializableElementForTest(xmlTag + 2, value + 2, NUnitElementType.Test); NUnitFilterContainerElementForTest element = new NUnitFilterContainerElementForTest(parent, NUnitElementType.And); Assert.IsNull(element.Child); element.SetChild(child); Assert.AreSame(child, element.Child); }
TestIdThrowsArgumentExceptionWhenMultipleTestIdsContainsOnlyNullOrEmptyValues() { const string value = "Value_1"; const string xmlTag = "name_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 id = element.Id(null, string.Empty); }); }
public void TestToXmlStringThrowsNullArgumentExceptionWhenChildNull( [Values] bool withXmlTag) { const string valueParent = "Value_1"; const string xmlTagParent = "name_1"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTagParent, valueParent, NUnitElementType.Test); NUnitFilterContainerElementForTest element = new NUnitFilterContainerElementForTest(parent, NUnitElementType.And); Assert.IsNull(element.Child); Assert.Throws( Is.TypeOf <ArgumentNullException>().And.Message .EqualTo("The Child cannot be null. (Parameter 'Child')"), () => element.ToXmlString(withXmlTag)); }
public void TestParentPropertyReturnsParentProvidedWithConstructor( [Values] bool isNull) { const string value = "Value_1"; const string xmlTag = "name_1"; XmlSerializableElementForTest parent = isNull ? null : new XmlSerializableElementForTest(xmlTag, value, NUnitElementType.Test); NUnitElementType elementType = isNull ? NUnitElementType.RootFilter : NUnitElementType.And; INUnitFilterContainerElementInternal element = new NUnitFilterContainerElement(parent, elementType); if (isNull) { Assert.IsNull(element.Parent); } else { Assert.AreSame(parent, element.Parent); } }
public void TestBuildThrowsArgumentExceptionWhenLeafElementChildIsNotNull() { const string value = "Value_"; const string xmlTag = "name_"; NUnitFilterContainerElementForTest root = new NUnitFilterContainerElementForTest(null, NUnitElementType.RootFilter); XmlSerializableElementForTest leafChild = new XmlSerializableElementForTest(xmlTag + 1, value + 1, NUnitElementType.Test); root.SetChild(leafChild); Assert.IsNotNull(root.Child); Assert.Throws( Is.TypeOf <ArgumentException>().And.Message .EqualTo( "The leaf element's child is not null thus the provided leaf element is not the true leaf element." + " This may indicate an error in the construction or parsing of the filter. (Parameter 'leafElement')"), () => NUnitFilter.Build(root)); }
public void TestNameThrowsArgumentExceptionWhenNameElementNameIsNullOrEmpty( [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 nameElement = element.Name(name); }); }
public void TestIdThrowsArgumentExceptionWhenTestIdArrayNullOrEmpty( [Values] bool isNull) { string[] names = isNull ? null : Array.Empty <string>(); const string value = "Value_1"; const string xmlTag = "name_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 testIds cannot be null or empty. (Parameter 'testIds')"), () => { // ReSharper disable once UnusedVariable INUnitFilterElement id = element.Id(names); }); }
/// <summary> /// Generic test for Test(Method)ThrowsInvalidOperationExceptionWhenChildIsAlreadySet. /// </summary> /// <param name="testFunction"> /// The function under test provided with the <see cref="NUnitFilterContainerElement" />, /// <see cref="INUnitFilterElementInternal.ElementName" />, and /// <see cref="INUnitFilterElementInternal.IsRegularExpression" /> /// </param> private static void TestElementMethodThrowsInvalidOperationExceptionWhenChildIsAlreadySet( Action <NUnitFilterContainerElement, string, bool> testFunction) { const string name = "element_1"; const string value = "Value_"; const string xmlTag = "name_"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag + 1, value + 1, NUnitElementType.Test); XmlSerializableElementForTest child = new XmlSerializableElementForTest(xmlTag + 2, value + 2, NUnitElementType.Test); NUnitFilterContainerElementForTest element = new NUnitFilterContainerElementForTest(parent, NUnitElementType.And); element.SetChild(child); Assert.Throws( Is.TypeOf <InvalidOperationException>().And.Message .EqualTo("The child element has already been set for this instance."), () => { testFunction(element, name, false); }); }
public void TestIdWithSingleTestIdSetsChildAndReturnsNewAndElementWithParent() { 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 id = (INUnitFilterElementInternal)element.Id(name); Assert.IsNotNull(id); Assert.AreEqual(NUnitElementType.Id, id.ElementType); Assert.AreSame(element, id.Parent); Assert.AreSame(id, element.Child); Assert.AreEqual(name, id.ElementName); Assert.IsNull(id.ElementValue); Assert.IsFalse(id.IsRegularExpression); }
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); }
public void TestOrPropertyThrowsInvalidOperationExceptionWhenChildIsAlreadySet() { const string name = "name_1"; const string value = "Value_"; const string xmlTag = "child_"; NUnitFilterContainerElement parent = new NUnitFilterContainerElement(null, NUnitElementType.RootFilter); XmlSerializableElementForTest child = new XmlSerializableElementForTest(xmlTag + 2, value + 2, NUnitElementType.Test); NUnitFilterElementForTest element = new NUnitFilterElementForTest(parent, NUnitElementType.Property, name, false, value); element.SetChild(child); Assert.Throws( Is.TypeOf <InvalidOperationException>().And.Message .EqualTo("The child element has already been set for this instance."), () => { // ReSharper disable once UnusedVariable INUnitFilterElementCollection or = element.Or; }); }
public void TestNotPropertyThrowsInvalidOperationExceptionWhenChildIsAlreadySet() { const string value = "Value_"; const string xmlTag = "name_"; XmlSerializableElementForTest parent = new XmlSerializableElementForTest(xmlTag + 1, value + 1, NUnitElementType.Test); XmlSerializableElementForTest child = new XmlSerializableElementForTest(xmlTag + 2, value + 2, NUnitElementType.Test); NUnitFilterElementCollectionForTest element = new NUnitFilterElementCollectionForTest(parent, NUnitElementType.And); element.SetChild(child); Assert.Throws( Is.TypeOf <InvalidOperationException>().And.Message .EqualTo("The child element has already been set for this instance."), // ReSharper disable once UnusedVariable () => { INUnitFilterContainerElement not = element.Not; }); }