public void Test_01_Construction() { FileFilters filter1 = new FileFilters("Word Documents (*.doc)|*.doc"); Assert.IsTrue(filter1.Count == 1); Assert.IsTrue(filter1.GetDescription(0) == "Word Documents (*.doc)"); Assert.IsTrue(filter1.GetFilter(0) == "*.doc"); Assert.IsTrue(filter1[0] != null, "Failed to create the regular expression for the filter"); Assert.IsTrue(((Regex)filter1[0]).ToString() == @".+\.doc$"); FileFilters filter2 = new FileFilters("Excel Document (*.xls)|*.xls|Word Documents (*.doc)|*.doc|All Files(*.*)|*.*"); Assert.IsTrue(filter2.Count == 3); Assert.IsTrue(filter2.GetDescription(0) == "Excel Document (*.xls)"); Assert.IsTrue(filter2.GetFilter(0) == "*.xls"); Assert.IsTrue(filter2[0] != null, "Failed to create the regular expression for the filter"); Assert.IsTrue(((Regex)filter2[0]).ToString() == @".+\.xls$"); Assert.IsTrue(filter2.GetDescription(1) == "Word Documents (*.doc)"); Assert.IsTrue(filter2.GetFilter(1) == "*.doc"); Assert.IsTrue(filter2[1] != null, "Failed to create the regular expression for the filter"); Assert.IsTrue(((Regex)filter2[1]).ToString() == @".+\.doc$"); Assert.IsTrue(filter2.GetDescription(2) == "All Files(*.*)"); Assert.IsTrue(filter2.GetFilter(2) == "*.*"); Assert.IsTrue(filter2[2] != null, "Failed to create the regular expression for the filter"); Assert.IsTrue(((Regex)filter2[2]).ToString() == @".+"); }
public void Test_02_WithMultipleMasks() { FileFilters filter1 = new FileFilters("Word & Excel (*.doc,*.xls)|*.doc,*.xls"); Assert.IsTrue(filter1.Count == 1); Assert.IsTrue(filter1.GetDescription(0) == "Word & Excel (*.doc,*.xls)"); Assert.IsTrue(filter1.GetFilter(0) == "*.doc,*.xls"); Assert.IsTrue(filter1[0] != null, "Failed to create the regular expression for the filter"); Assert.IsTrue(((Regex)filter1[0]).ToString() == @"(.+\.doc$)|(.+\.xls$)"); }