예제 #1
0
        private void TestFourFiles(IResultSaver saver)
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "rihter.txt");
            fileSource.Add(FileDir + "rihter2.txt");
            fileSource.Add(FileDir + "rihter3.txt");
            fileSource.Add(FileDir + "rihter4.txt");

            var appl = new Appl(fileSource);

            appl.Execute(saver);
        }
예제 #2
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");
        }
예제 #3
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");
        }
예제 #4
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");
        }
예제 #5
0
        public void TestOneWord()
        {
            var fileSource = new FileNameSourceStub();
            var fileDir    = "..\\..\\";

            fileSource.Add(fileDir + "OneWord..txt");

            Assert.AreEqual(1, fileSource.FileNames.Count, "count");
        }
예제 #6
0
        public void TestTwoFiles()
        {
            var fileSource = new FileNameSourceStub();

            fileSource.Add(FileDir + "TwoDifferentWords.txt");
            fileSource.Add(FileDir + "OneWord..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(2, wordCount1.Count, "count one");

            var wordCount2 = resultSaver.Items[1];

            Assert.AreEqual("two", wordCount2.Word, "word two");
            Assert.AreEqual(1, wordCount2.Count, "count two");
        }
예제 #7
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");
        }
예제 #8
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");
        }
예제 #9
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");
        }