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 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)); }