public void Should_RaiseException_When_SingleWord_IsPassed() { //arrange IStringOperation opertaion = new StringOperation(); //act IEnumerable <WordDataDto> data = (opertaion.CountFrequentWords("AlphaFX")); //assert Assert.Single(data); }
public void Should_RaiseException_When_Whitespace_IsPassed() { //arrange IStringOperation opertaion = new StringOperation(); //act void act() => opertaion.CountFrequentWords(" "); //assert Assert.Throws <ArgumentException>(act); }
public void Should_ReturnAllWordWithAlphaCount2_When_StringWithLessThan10Word_And_1RepeatingWord_IsPassed() { //arrange IStringOperation opertaion = new StringOperation(); //act IEnumerable <WordDataDto> data = opertaion.CountFrequentWords("Alpha Alpha FX - Count of Word"); //assert Assert.Equal(6, data.Count()); Assert.Equal(2, data.Single(b => b.Word.Equals("Alpha")).Count); }
public void Should_ReturnAllWordWithSingleAppearance_When_StringWithLessThan10Word_And_AllUniqueWord_IsPassed() { //arrange IStringOperation opertaion = new StringOperation(); //act IEnumerable <WordDataDto> data = (opertaion.CountFrequentWords("Alpha FX - Count of Word")); //assert Assert.Equal(6, data.Count()); Assert.True(data.All(a => a.Count == 1)); }
public void Should_ReturnTop10Words_When_String_IsPassed() { //arrange IStringOperation opertaion = new StringOperation(); //act string fileData = File.ReadAllText("Lord of the Ring.txt"); List <WordDataDto> data = new List <WordDataDto>( opertaion.CountFrequentWords(fileData)); //assert int count = data.Count(); Assert.Equal(10, count); }
public void Should_ReturnAllWordIgnoringRepeatingSpaces_When_String_IsPassed() { //arrange IStringOperation opertaion = new StringOperation(); //act IEnumerable <WordDataDto> data = opertaion.CountFrequentWords("Alpha Alpha FX FX FX F F X X X X yyy yyy - Count of Word"); //assert Assert.Equal(9, data.Count()); Assert.Equal(2, data.Single(b => b.Word.Equals("Alpha")).Count); Assert.Equal(3, data.Single(b => b.Word.Equals("FX")).Count); Assert.Equal(2, data.Single(b => b.Word.Equals("F")).Count); Assert.Equal(4, data.Single(b => b.Word.Equals("X")).Count); Assert.Equal(2, data.Single(b => b.Word.Equals("yyy")).Count); }
public void Should_ReturnAllWords_When_StringWithLessThan10RepeatingWords_IsPassed() { //arrange IStringOperation opertaion = new StringOperation(); //act IEnumerable <WordDataDto> data = opertaion.CountFrequentWords("Alpha Alpha FX FX FX F F X X X X - Count of Word"); //assert Assert.Equal(8, data.Count()); Assert.Equal(2, data.Single(b => b.Word.Equals("Alpha")).Count); Assert.Equal(3, data.Single(b => b.Word.Equals("FX")).Count); Assert.Equal(2, data.Single(b => b.Word.Equals("F")).Count); Assert.Equal(4, data.Single(b => b.Word.Equals("X")).Count); Assert.Equal("X", data.ToArray()[0].Word); Assert.Equal("FX", data.ToArray()[1].Word); Assert.Equal("Alpha", data.ToArray()[2].Word); Assert.Equal("F", data.ToArray()[3].Word); }