예제 #1
0
        public static bool TestGetCollection()
        {
            //arrange
            ISet <string> expected = new HashSet <string>();

            expected.Add("asd");
            IStringFilter instance = new StringFilter(expected);

            //act
            ISet <string> actual = instance.GetCollection();

            //assert
            return(actual.SequenceEqual(expected));
        }
예제 #2
0
        public static bool TestRemove()
        {
            //arrange
            ISet <string> k = new HashSet <string>();

            k.Add("sdfgh");
            k.Add("asd");
            IStringFilter b = new StringFilter(k);

            //act
            b.Remove("asd");

            //assert
            if (b.GetCollection().Last() == "asd")
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
        public IEnumerator <string> GetStringsContaining(string chars)
        {
            if (chars == null || chars == "")
            {
                return(rowset.GetEnumerator());
            }

            IStringFilter resultSet = new StringFilter();

            foreach (string elem in rowset)
            {
                if (elem.Contains(chars))
                {
                    resultSet.Add(elem);
                }
            }

            return(resultSet.GetCollection().GetEnumerator());
        }
예제 #4
0
        public static bool TestRemoveAll()
        {
            //arrange
            ISet <string> k = new HashSet <string>();

            k.Add("dfghnm,");
            k.Add("oooooooooonm,");
            k.Add("yjklm,");
            IStringFilter b = new StringFilter(k);

            //act
            b.RemoveAll();

            //assert
            if (b.GetCollection().Count() != 0)
            {
                return(false);
            }

            return(true);
        }
예제 #5
0
        public static bool TestAdd()
        {
            //arrange
            ISet <string> forActual = new HashSet <string>();

            forActual.Add("abcde");
            IStringFilter actual = new StringFilter(forActual);

            ISet <string> forExpected = new HashSet <string>();

            forExpected.Add("abcde");
            forExpected.Add("gg");
            IStringFilter expected = new StringFilter(forExpected);

            //act
            actual.Add("gg");

            //assert

            return(IsEqualSet(actual.GetCollection(), expected.GetCollection()));
        }
예제 #6
0
        public static bool TestGetStringsByNumberFormat()
        {
            //arrange
            ISet <string> actualSet = new HashSet <string>();

            actualSet.Add("-5.67");
            actualSet.Add("(456)767899-0000");
            actualSet.Add("3 567");
            actualSet.Add("56-87 6");
            IStringFilter actualStringFilter = new StringFilter(actualSet);

            ISet <string> expectedSet = new HashSet <string>();

            //expectedSet.Add("-5.67");
            expectedSet.Add("(456)767899-0000");
            //expectedSet.Add("3 567");
            IStringFilter        expectedStringFilter = new StringFilter(expectedSet);
            IEnumerator <string> expected             = expectedStringFilter.GetCollection().GetEnumerator();

            //act
            IEnumerator <string> actual = actualStringFilter.GetStringsByNumberFormat("(###)######-####");

            ISet <string> setFromExpectedEnumerator = new HashSet <string>();

            while (expected.MoveNext())
            {
                setFromExpectedEnumerator.Add(expected.Current);
            }

            ISet <string> setFromActualEnumerator = new HashSet <string>();

            while (actual.MoveNext())
            {
                setFromActualEnumerator.Add(actual.Current);
            }

            //assert
            return(setFromExpectedEnumerator.SequenceEqual(setFromActualEnumerator));
        }
예제 #7
0
        public static bool TestGetStringsByPattern()
        {
            //arrange
            ISet <string> actualSet = new HashSet <string>();

            actualSet.Add("john");
            actualSet.Add("johny");
            actualSet.Add("sarah");
            actualSet.Add("bob");
            IStringFilter actualStringFilter = new StringFilter(actualSet);

            ISet <string> expectedSet = new HashSet <string>();

            //expectedSet.Add("john");
            expectedSet.Add("johny");
            IStringFilter        expectedStringFilter = new StringFilter(expectedSet);
            IEnumerator <string> expected             = expectedStringFilter.GetCollection().GetEnumerator();

            //act
            IEnumerator <string> actual = actualStringFilter.GetStringsByPattern(@"j\w+y");

            ISet <string> setFromExpectedEnumerator = new HashSet <string>();

            while (expected.MoveNext())
            {
                setFromExpectedEnumerator.Add(expected.Current);
            }

            ISet <string> setFromActualEnumerator = new HashSet <string>();

            while (actual.MoveNext())
            {
                setFromActualEnumerator.Add(actual.Current);
            }

            //assert
            return(setFromExpectedEnumerator.SequenceEqual(setFromActualEnumerator));
        }