Exemplo n.º 1
0
        public void TestDogheart()
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "dogheart.txt");

            var appl        = new Appl(fileSource);
            var resultSaver = new ResultSaverSpy();

            appl.Execute(resultSaver);

            Assert.AreEqual(8268, resultSaver.Items.Count, "words count");
            var ordered = resultSaver.Items.OrderByDescending(w => w.Count).ToArray();

            var first = ordered[0];

            Assert.AreEqual("-", first.Word, "first word");
            Assert.AreEqual(1585, first.Count, "first count");

            var second = ordered[1];

            Assert.AreEqual("и", second.Word, "second word");
            Assert.AreEqual(938, second.Count, "second count");

            var third = ordered[2];

            Assert.AreEqual("в", third.Word, "third word");
            Assert.AreEqual(798, third.Count, "third count");
        }
Exemplo n.º 2
0
        public void TestMaster()
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "master.txt");

            var appl        = new Appl(fileSource);
            var resultSaver = new ResultSaverSpy();

            appl.Execute(resultSaver);

            Assert.AreEqual(26425, resultSaver.Items.Count, "words count");
            var ordered = resultSaver.Items.OrderByDescending(w => w.Count).ToArray();

            var first = ordered[0];

            Assert.AreEqual("-", first.Word, "first word");
            Assert.AreEqual(5041, first.Count, "first count");

            var second = ordered[1];

            Assert.AreEqual("и", second.Word, "second word");
            Assert.AreEqual(4967, second.Count, "second count");

            var third = ordered[2];

            Assert.AreEqual("в", third.Word, "third word");
            Assert.AreEqual(3617, third.Count, "third count");
        }
Exemplo n.º 3
0
        public void TestFourFiles()
        {
            var resultSaver = new ResultSaverSpy();

            TestFourFiles(resultSaver);

            Assert.AreEqual(1454, resultSaver.Items.Count, "words count");
            var firstWord = resultSaver.Items.First();

            Assert.AreEqual("глава", firstWord.Word, "word");
            Assert.AreEqual(24, firstWord.Count, "count");
        }
Exemplo n.º 4
0
        public void TestTwoBigFiles()
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "rihter.txt");
            fileSource.Add(FileDir + "xunit.txt");

            var appl        = new Appl(fileSource);
            var resultSaver = new ResultSaverSpy();

            appl.Execute(resultSaver);

            Assert.AreEqual(1755, resultSaver.Items.Count, "words count");
        }
Exemplo n.º 5
0
        public void TestTwoEqualsWordTwoLines()
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "TwoEqualsWordsTwoLines.txt");

            var appl        = new Appl(fileSource);
            var resultSaver = new ResultSaverSpy();

            appl.Execute(resultSaver);

            Assert.AreEqual(1, resultSaver.Items.Count, "words count");
            var wordCount = resultSaver.Items.First();

            Assert.AreEqual("one", wordCount.Word, "word");
            Assert.AreEqual(2, wordCount.Count, "count");
        }
Exemplo n.º 6
0
        public void TestRihter()
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "rihter.txt");

            var appl        = new Appl(fileSource);
            var resultSaver = new ResultSaverSpy();

            appl.Execute(resultSaver);

            Assert.AreEqual(1454, resultSaver.Items.Count, "words count");
            var firstWord = resultSaver.Items.First();

            Assert.AreEqual("глава", firstWord.Word, "word");
            Assert.AreEqual(6, firstWord.Count, "count");
        }
Exemplo n.º 7
0
        public void TestTwoDifferentWord()
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "TwoDifferentWords.txt");

            var appl        = new Appl(fileSource);
            var resultSaver = new ResultSaverSpy();

            appl.Execute(resultSaver);

            Assert.AreEqual(2, resultSaver.Items.Count, "words count");
            var wordCount1 = resultSaver.Items.First();

            Assert.AreEqual("one", wordCount1.Word, "word one");
            Assert.AreEqual(1, wordCount1.Count, "count one");

            var wordCount2 = resultSaver.Items[1];

            Assert.AreEqual("two", wordCount2.Word, "word two");
            Assert.AreEqual(1, wordCount2.Count, "count two");
        }
Exemplo n.º 8
0
        public void TestIso8859()
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "iso8859.txt");

            var appl        = new Appl(fileSource);
            var resultSaver = new ResultSaverSpy();

            appl.Execute(resultSaver);

            Assert.AreEqual(2, resultSaver.Items.Count, "words count");

            var first = resultSaver.Items[0];

            Assert.AreEqual("one", first.Word, "first word");
            Assert.AreEqual(1, first.Count, "first count");

            var second = resultSaver.Items[1];

            Assert.AreEqual("один", second.Word, "second word");
            Assert.AreEqual(1, second.Count, "second count");
        }