public void RandomTestWithCustomMock() { //Arrange var mockedRandomNumberGenerator = new MockedRandomNumberGenerator(); var thing = new RandomAdder(mockedRandomNumberGenerator); //Act var result = thing.AddRandomly(4); //Assert Assert.AreEqual(6, result); }
public void RandomTestWithMoq() { //Arrange var mockedRandomNumberGenerator = new Mock <RandomNumberGenerator>(); mockedRandomNumberGenerator.SetupGet(x => x.RandomNumberToAdd).Returns(2); var thing = new RandomAdder(mockedRandomNumberGenerator.Object); //Act var result = thing.AddRandomly(4); //Assert Assert.AreEqual(6, result); }