예제 #1
0
        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);
        }
예제 #2
0
        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);
        }