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 TestNameSetsChildAndReturnsNewAndElementWithParent( [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 nameElement = (INUnitFilterElementInternal)element.Name(name, isRegularExpression); Assert.IsNotNull(nameElement); Assert.AreEqual(NUnitElementType.NUnitName, nameElement.ElementType); Assert.AreSame(element, nameElement.Parent); Assert.AreSame(nameElement, element.Child); Assert.AreEqual(name, nameElement.ElementName); Assert.IsNull(nameElement.ElementValue); Assert.AreEqual(isRegularExpression, nameElement.IsRegularExpression); }