Beispiel #1
0
        public void Contains_ExclusionTest()
        {
            //Arrange
            string filePath      = "somepath";
            string language      = "en";
            string extraPath     = "extraPath";
            string exclusionPath = "exclusionPath";

            Dictionary <string, bool> pathCalls = new Dictionary <string, bool>()
            {
                { filePath, false },
                { extraPath, false },
                { exclusionPath, false },
            };

            Func <string, IEnumerable <string> > wordListRetriever = (path) =>
            {
                pathCalls[path] = true;
                if (path == filePath)
                {
                    return(new string[] { "abc", "Abc", "badword" }); // duplicates are allowed
                }
                else if (path == extraPath)
                {
                    return(new string[] { "1243,", "bcd" });
                }
                else if (path == exclusionPath)
                {
                    return(new string[] { "1243,", "badword" });
                }

                return(null);
            };
            var objectUnderTest = new HashtableWordListSource(filePath, language, extraPath, exclusionPath, wordListRetriever);

            //Act
            objectUnderTest.Load();

            //Assert
            Assert.AreEqual(true, pathCalls[filePath]);

            Assert.IsFalse(objectUnderTest.Contains("1243,"));    //extra but not allowed
            Assert.IsFalse(objectUnderTest.Contains("badword,")); // not allowed

            Assert.IsTrue(objectUnderTest.Contains("abc"));       // exact match
            Assert.IsTrue(objectUnderTest.Contains("bcd"));       // exact match
            Assert.IsTrue(objectUnderTest.Contains("ABC"));       //case invariant match
            Assert.IsTrue(objectUnderTest.Contains("bcd"));       //extra
            Assert.IsTrue(objectUnderTest.Contains("bCd"));       //extra case invariant match
        }
Beispiel #2
0
        public void Contains_BaseTest()
        {
            //Arrange
            string filePath      = "somepath";
            string language      = "en";
            string extraPath     = null;
            string exclusionPath = null;

            Dictionary <string, bool> pathCalls = new Dictionary <string, bool>()
            {
                { filePath, false },
                { "extraPath", false },
                { "exclusionPath", false },
            };

            Func <string, IEnumerable <string> > wordListRetriever = (path) =>
            {
                pathCalls[path] = true;
                if (path == filePath)
                {
                    return(new string[] { "abc", "Abc", "bcd" });
                }
                return(null);
            };
            var objectUnderTest = new HashtableWordListSource(filePath, language, extraPath, exclusionPath, wordListRetriever);

            //Act
            objectUnderTest.Load();

            //Assert
            Assert.AreEqual(true, pathCalls[filePath]);

            Assert.IsFalse(objectUnderTest.Contains(null));         // bad value
            Assert.IsFalse(objectUnderTest.Contains(string.Empty)); // bad value
            Assert.IsFalse(objectUnderTest.Contains("peiopwei"));   // not a word value

            Assert.IsTrue(objectUnderTest.Contains("abc"));         // exact match
            Assert.IsTrue(objectUnderTest.Contains("bcd"));         // exact match
            Assert.IsTrue(objectUnderTest.Contains("ABC"));         //case invariant match
        }