Exemplo n.º 1
0
        [Test] public void TestGetWords()
        {
            Assert.Throws <FormatException>(() => WordDownloader.GetWords(string.Empty));
            Assert.Throws <FormatException>(() => WordDownloader.GetWords("<span class='mot'>"));
            var words = WordDownloader.GetWords("<span class='mot'>UN DEUX</span>");

            Assert.AreEqual(2, words.Count);
            Assert.IsTrue(words.Contains("UN"));
            Assert.IsTrue(words.Contains("DEUX"));
        }
Exemplo n.º 2
0
        [Test] public void TestGetCount()
        {
            Assert.Throws <FormatException>(() => WordDownloader.GetCount(string.Empty));
            int count = WordDownloader.GetCount("Il y a 2 mots");

            Assert.AreEqual(2, count);
            int one = WordDownloader.GetCount("Il y a un seul mot... mots");

            Assert.AreEqual(1, one);
        }
Exemplo n.º 3
0
        [Test] public void TestParseContent()
        {
            Assert.Throws <FormatException>(() => WordDownloader.ParseContent(string.Empty));
            Assert.Throws <FormatException>(() => WordDownloader.ParseContent("<span class='mot'>"));
            Assert.Throws <FormatException>(() => WordDownloader.ParseContent("<span class='mot'></span>"));
            var wc = WordDownloader.ParseContent("Il y a 2 mots <span class='mot'>UN DEUX</span>");

            Assert.AreEqual(2, wc.Count);
            Assert.AreEqual(2, wc.Words.Count);
            Assert.IsTrue(wc.Words.Contains("UN"));
            Assert.IsTrue(wc.Words.Contains("DEUX"));
            Assert.IsTrue(wc.IsFull);
        }
Exemplo n.º 4
0
        [Test] public void TestParseContentCN()
        {
            const string ResourcePath = "Ded.Wordox.Resources.";
            var          resources    = new AssemblyResources(typeof(WordDownloaderTest), ResourcePath);
            string       content      = resources.GetContent("mots9lettresdebutantcn.htm");
            WordContent  wc           = WordDownloader.ParseContent(content);

            Assert.AreEqual(1, wc.Count);
            Assert.AreEqual(1, wc.Words.Count);
            Assert.IsTrue(wc.IsFull);
            foreach (string w in wc.Words)
            {
                Assert.AreEqual(9, w.Length);
            }
        }
Exemplo n.º 5
0
        [Test] public void TestParseContent6()
        {
            const string ResourcePath = "Ded.Wordox.Resources.";
            var          resources    = new AssemblyResources(typeof(WordDownloaderTest), ResourcePath);
            string       content      = resources.GetContent("mots6lettres.htm");
            WordContent  wc           = WordDownloader.ParseContent(content);

            Assert.AreEqual(17318, wc.Count);
            Assert.AreEqual(17318 - 10175, wc.Words.Count);
            Assert.IsFalse(wc.IsFull);
            foreach (string w in wc.Words)
            {
                Assert.AreEqual(6, w.Length);
            }
        }