public void Match_SingleName() { var filter = new SimpleNameFilter(_dummyFixture.FullName); Assert.That(filter.Match(_dummyFixture)); Assert.False(filter.Match(_anotherFixture)); }
public void SimpleNameFilter_SingleNameConstructor() { var filter = new SimpleNameFilter(dummyName); Assert.False(filter.IsEmpty); Assert.That(filter.Match(dummyFixture)); Assert.False(filter.Match(anotherFixture)); }
public void Match_MultipleNames() { var filter = new SimpleNameFilter(new string[] { _dummyFixture.FullName, _anotherFixture.FullName }); Assert.That(filter.Match(_dummyFixture)); Assert.That(filter.Match(_anotherFixture)); Assert.False(filter.Match(_yetAnotherFixture)); }
public void SimpleNameFilter_MultipleNameConstructor() { var filter = new SimpleNameFilter(new string[] { dummyName, anotherName }); Assert.False(filter.IsEmpty); Assert.That(filter.Match(dummyFixture)); Assert.That(filter.Match(anotherFixture)); Assert.False(filter.Match(yetAnotherFixture)); }
public void ExplicitMatch_SingleName() { var filter = new SimpleNameFilter(_dummyFixture.FullName); Assert.That(filter.IsExplicitMatch(_topLevelSuite)); Assert.That(filter.IsExplicitMatch(_dummyFixture)); Assert.False(filter.IsExplicitMatch(_dummyFixture.Tests[0])); Assert.False(filter.IsExplicitMatch(_anotherFixture)); }
public void AddNames() { var filter = new SimpleNameFilter(); filter.Add(_dummyFixture.FullName); filter.Add(_anotherFixture.FullName); Assert.That(filter.Match(_dummyFixture)); Assert.That(filter.Match(_anotherFixture)); Assert.False(filter.Match(_yetAnotherFixture)); }
public void SimpleNameFilter_AddNames() { var filter = new SimpleNameFilter(); filter.Add(dummyName); filter.Add(anotherName); Assert.False(filter.IsEmpty); Assert.That(filter.Match(dummyFixture)); Assert.That(filter.Match(anotherFixture)); Assert.False(filter.Match(yetAnotherFixture)); }
public void ExplicitMatch_MultipleNames() { var filter = new SimpleNameFilter(new string[] { _dummyFixture.FullName, _anotherFixture.FullName }); Assert.That(filter.IsExplicitMatch(_topLevelSuite)); Assert.That(filter.IsExplicitMatch(_dummyFixture)); Assert.False(filter.IsExplicitMatch(_dummyFixture.Tests[0])); Assert.That(filter.IsExplicitMatch(_anotherFixture)); Assert.False(filter.IsExplicitMatch(_anotherFixture.Tests[0])); Assert.False(filter.IsExplicitMatch(_yetAnotherFixture)); }
public void Pass_MultipleNames() { var filter = new SimpleNameFilter(new string[] { _dummyFixture.FullName, _anotherFixture.FullName }); Assert.That(filter.Pass(_topLevelSuite)); Assert.That(filter.Pass(_dummyFixture)); Assert.That(filter.Pass(_dummyFixture.Tests[0])); Assert.That(filter.Pass(_anotherFixture)); Assert.That(filter.Pass(_anotherFixture.Tests[0])); Assert.False(filter.Pass(_yetAnotherFixture)); }
private static TestFilter FromXml(TNode node) { switch (node.Name) { case "filter": case "and": var andFilter = new AndFilter(); foreach (var childNode in node.ChildNodes) andFilter.Add(FromXml(childNode)); return andFilter; case "or": var orFilter = new OrFilter(); foreach (var childNode in node.ChildNodes) orFilter.Add(FromXml(childNode)); return orFilter; case "not": return new NotFilter(FromXml(node.FirstChild)); case "id": var idFilter = new IdFilter(); if (node.Value != null) foreach (string id in node.Value.Split(COMMA)) idFilter.Add(id); return idFilter; case "tests": var testFilter = new SimpleNameFilter(); foreach (var childNode in node.SelectNodes("test")) testFilter.Add(childNode.Value); return testFilter; case "cat": var catFilter = new CategoryFilter(); if (node.Value != null) foreach (string cat in node.Value.Split(COMMA)) catFilter.AddCategory(cat); return catFilter; default: throw new ArgumentException("Invalid filter element: " + node.Name, "xmlNode"); } }
public static TestFilter FromXml(string xmlText) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlText); XmlNode topNode = doc.FirstChild; if (topNode.Name != "filter") throw new Exception("Expected filter element at top level"); // Initially, an empty filter TestFilter result = TestFilter.Empty; bool isEmptyResult = true; XmlNodeList testNodes = topNode.SelectNodes("tests/test"); XmlNodeList includeNodes = topNode.SelectNodes("include/category"); XmlNodeList excludeNodes = topNode.SelectNodes("exclude/category"); if (testNodes.Count > 0) { SimpleNameFilter nameFilter = new SimpleNameFilter(); foreach (XmlNode testNode in topNode.SelectNodes("tests/test")) nameFilter.Add(testNode.InnerText); result = nameFilter; isEmptyResult = false; } if (includeNodes.Count > 0) { //CategoryFilter includeFilter = new CategoryFilter(); //foreach (XmlNode includeNode in includeNodes) // includeFilter.AddCategory(includeNode.InnerText); // Temporarily just look at the first element XmlNode includeNode = includeNodes[0]; TestFilter includeFilter = new CategoryExpression(includeNode.InnerText).Filter; if (isEmptyResult) result = includeFilter; else result = new AndFilter(result, includeFilter); isEmptyResult = false; } if (excludeNodes.Count > 0) { CategoryFilter categoryFilter = new CategoryFilter(); foreach (XmlNode excludeNode in excludeNodes) categoryFilter.AddCategory(excludeNode.InnerText); TestFilter excludeFilter = new NotFilter(categoryFilter); if (isEmptyResult) result = excludeFilter; else result = new AndFilter(result, excludeFilter); isEmptyResult = false; } return result; }
public void IsNotEmpty() { var filter = new SimpleNameFilter(_dummyFixture.FullName); Assert.False(filter.IsEmpty); }
private static TestFilter FromXml(XmlNode xmlNode) { switch (xmlNode.Name) { case "filter": case "and": var andFilter = new AndFilter(); foreach (XmlNode childNode in xmlNode.ChildNodes) andFilter.Add(FromXml(childNode)); return andFilter; case "or": var orFilter = new OrFilter(); foreach (System.Xml.XmlNode childNode in xmlNode.ChildNodes) orFilter.Add(FromXml(childNode)); return orFilter; case "not": return new NotFilter(FromXml(xmlNode.FirstChild)); case "id": var idFilter = new IdFilter(); foreach (string id in xmlNode.InnerText.Split(COMMA)) idFilter.Add(int.Parse(id)); return idFilter; case "tests": var testFilter = new SimpleNameFilter(); foreach (XmlNode childNode in xmlNode.SelectNodes("test")) testFilter.Add(childNode.InnerText); return testFilter; case "cat": var catFilter = new CategoryFilter(); foreach (string cat in xmlNode.InnerText.Split(COMMA)) catFilter.AddCategory(cat); return catFilter; default: throw new ArgumentException("Invalid filter element: " + xmlNode.Name, "xmlNode"); } }