public void ChangeBalanceTest() { // Arrange var clientRepositoryMock = Substitute.For <IClientRepository>(); var sut = new ClientManager(clientRepositoryMock); int clientID = 12; decimal amount = 300; clientRepositoryMock .IsClientExist(Arg.Is <int>(clientID)) .Returns(true); // Act sut.ChangeBalance(clientID, amount); // Asserts clientRepositoryMock.Received(1).ChangeBalance(clientID, amount); }
public void ChangeBalanceDidntExistTest() { // Arrange var clientRepositoryMock = Substitute.For <IClientRepository>(); var sut = new ClientManager(clientRepositoryMock); int clientID = 12; decimal amount = 300; clientRepositoryMock .IsClientExist(Arg.Is <int>(clientID)) .Returns(false); // Act sut.ChangeBalance(clientID, amount); Assert.Fail("Expected Exception"); // Asserts clientRepositoryMock.DidNotReceive().ChangeBalance(clientID, amount); }