public void RandomSymbolFromStringTest_LongString_20times_NotCompare() { // arrange var line = "asadfghjkhkjghgdfretyui"; var fakeRandomIntegerProvider = new Mock <IGenerateInteger>(); fakeRandomIntegerProvider.Setup(f => f.Generate(0, line.Length - 1)).Returns(0); var realRamdomIntegerProvider = new RandomIntegerProvider(); string valuesFromFake = string.Empty; string valuesFromReal = string.Empty; // act for (int i = 0; i < 20; i++) { valuesFromFake += LineParser.RandomSymbolFromString(line, fakeRandomIntegerProvider.Object); valuesFromReal += LineParser.RandomSymbolFromString(line, realRamdomIntegerProvider); } // assert fakeRandomIntegerProvider.Verify(f => f.Generate(0, line.Length - 1), Times.Exactly(20)); Assert.NotEqual(valuesFromReal, valuesFromFake); }
public void RandomSymbolFromStringTest_NullRandomIntegerProvider() { // arrange string s = "asdfgb"; RandomIntegerProvider rand = null; // act and assert Assert.Throws <ArgumentNullException>(() => LineParser.RandomSymbolFromString(s, rand)); }
public void RandomSymbolFromString_OneSymbolString_Symbol(string line, char actual) { // var intProvider = new RandomIntegerProvider(); // act var expected = LineParser.RandomSymbolFromString(line, intProvider); // assert Assert.Equal(expected, actual); }