public void UnitTest_FakeItEasy() { var mockBankAccount = A.Fake<IBankAccount>(); var mockView = A.Fake<IView>(); var presenter = new CustomerPresenter(mockView, mockBankAccount); A.CallTo(() => mockBankAccount.Debit(10)).Returns(100); var result = presenter.DebitCustomerAccount(10); Assert.AreEqual(100, result); Assert.IsTrue(typeof(IBankAccount).IsInstanceOfType(mockBankAccount)); }
public void UnitTest_Moq() { var mockBankAccount = new Moq.Mock<IBankAccount>(); var mockView = new Moq.Mock<IView>(); mockBankAccount.Setup(e => e.Debit(10)) .Returns(100); var presenter = new CustomerPresenter(mockView.Object, mockBankAccount.Object); var result = presenter.DebitCustomerAccount(10); Assert.AreEqual(100, result); Assert.IsTrue(typeof(IBankAccount).IsInstanceOfType(mockBankAccount.Object)); }
public void UnitTest_NSubstitute() { var mockBankAccount = Substitute.For<IBankAccount>(); var mockView = Substitute.For<IView>(); var presenter = new CustomerPresenter(mockView, mockBankAccount); mockBankAccount.Debit(10).Returns(100); var result = presenter.DebitCustomerAccount(10); Assert.AreEqual(100, result); Assert.IsTrue(typeof(IBankAccount).IsInstanceOfType(mockBankAccount)); }
public void UnitTest_NMock3() { _factory = new NMock.MockFactory(); var mockBankAccount = _factory.CreateMock<IBankAccount>(); var mockView = _factory.CreateMock<IView>(); mockBankAccount.Expects.One.MethodWith(_ => _.Debit(10)) .WillReturn(100); var presenter = new CustomerPresenter(mockView.MockObject, mockBankAccount.MockObject); var result = presenter.DebitCustomerAccount(10); Assert.AreEqual(100, result); Assert.IsTrue(typeof(IBankAccount).IsInstanceOfType(mockBankAccount.MockObject)); }