Exemplo n.º 1
0
        public void TransferFundsFromEurAmount_MockFramework_ShouldWork()
        {
            //arrange

            var source      = new Account(200);
            var destination = new Account(150);

            var rateEurRon    = 4.4F;
            var convertorMock = new Mock <ICurrencyConvertor>();

            convertorMock.Setup(_ => _.EurToRon(20)).Returns(20 * rateEurRon); // set mock to act as a TestDouble Stub - gives IndirectInputs to the SUT

            //act
            source.TransferFundsFromEurAmount(destination, 20.00F, convertorMock.Object);

            //assert
            Assert.AreEqual(150.00F + 20 * rateEurRon, destination.Balance);
            Assert.AreEqual(200.00F - 20 * rateEurRon, source.Balance);

            convertorMock.Verify(_ => _.EurToRon(20), Times.Once()); //verify behavior
        }