public void Lese_StopwordsDatei_Erwarte_Zeilen()
        {
            StopwordsProvider stopwordsProvider = new StopwordsProvider();
            List <string>     result            = stopwordsProvider.Read_Stopwords();

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count, Is.EqualTo(4));
        }
Пример #2
0
        //[TestCase("Marry had a little lamb.", 4)]
        //[TestCase("", 0)]
        public void Teste_Marry_Erwarte_Erfolg(string eingabe, int erwartetesErgebnis)
        {
            Words             words             = new Words();
            StopwordsProvider stopwordsProvider = new StopwordsProvider();

            int cntWords = new WordCount().Count_Words(eingabe);

            Assert.That(cntWords, Is.EqualTo(erwartetesErgebnis));
        }
        public void Lese_LeereDatei_Erwarte_Null()
        {
            string pathZuStopwords = $"{AppDomain.CurrentDomain.BaseDirectory}\\App_Data\\leer.txt";

            StopwordsProvider stopwordsProvider = new StopwordsProvider(pathZuStopwords);
            List <string>     result            = stopwordsProvider.Read_Stopwords();

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count, Is.EqualTo(0));
        }
Пример #4
0
        public void ReadStopwords_DateiExisitiertUndHat2Woerter_ErwarteInhaltMit2Woertern()
        {
            string filePath = @"C:\Temp\stopwords.txt";

            string[] lines = { "a", "on" };

            File.WriteAllLines(filePath, lines);

            IEnumerable <string> fileContent = StopwordsProvider.Read_stopwords();

            Assert.That(fileContent.Count(), Is.EqualTo(2));
        }
Пример #5
0
        public void ReadStopwords_DateiExisitiertUndLeer_ErwarteLeerenInhalt()
        {
            string filePath = @"C:\Temp\stopwords.txt";

            var file = File.Create(filePath);

            file.Close();

            IEnumerable <string> fileContent = StopwordsProvider.Read_stopwords();

            Assert.That(fileContent.Count(), Is.EqualTo(0));
        }
Пример #6
0
        public void GetStopWords_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            StopwordsProvider provider = CreateProvider();
            var expectedResult         = new List <string>()
            {
                "a", "the", "on", "off"
            };

            // Act
            ICollection <string> result = provider.GetStopWords();

            // Assert
            result.Should().BeEquivalentTo(expectedResult);
        }
Пример #7
0
        public void ReadStopwords_DateiExisitiertNicht_ErwarteFileNotFoundException()
        {
            string filePath = @"C:\Temp\stopwords.txt";

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            //Act
            ActualValueDelegate <object> testDelegate = () => StopwordsProvider.Read_stopwords();

            //Assert
            Assert.That(testDelegate, Throws.TypeOf <FileNotFoundException>());
        }
Пример #8
0
 public WordCount(StopwordsProvider stopwordsProvider)
 {
     _words             = new Words();
     _stopwordsProvider = stopwordsProvider;
 }
Пример #9
0
 public WordCount()
 {
     _words             = new Words();
     _stopwordsProvider = new StopwordsProvider();
 }