コード例 #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");
        }
コード例 #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");
        }
コード例 #3
0
ファイル: TestOneFile.cs プロジェクト: stovpyak/WordCounter
        public void TestOneWord()
        {
            var fileSource = new FileNameSourceStub();
            var fileDir    = "..\\..\\";

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

            Assert.AreEqual(1, fileSource.FileNames.Count, "count");
        }
コード例 #4
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);
        }
コード例 #5
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");
        }
コード例 #6
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");
        }
コード例 #7
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");
        }
コード例 #8
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");
        }
コード例 #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");
        }