public void Create_Account_Test() { var consoleMock = new Mock <IShell>(); consoleMock.SetupSequence(c => c.ReadLine()) .Returns("1111") .Returns("2000"); var repoMock = new Mock <IRepository>(); var accId = 0; decimal balance = 0; repoMock.Setup(r => r.Save(It.IsAny <Account>())) .Callback <Account>(a => (accId, balance) = (a.AccountId, a.Balance)); var createAccView = new CreateAccountView("fool", consoleMock.Object, repoMock.Object); createAccView.Show(); Assert.Equal(1111, accId); Assert.Equal(2000, balance); }
public void Create_Account_Test() { var consoleMock = new Mock <IShell>(); consoleMock.SetupSequence(c => c.ReadLine()) .Returns("1111") .Returns("2000"); var repoMock = new Mock <IRepository>(); var factoryMock = new Mock <IAccountFactory>(); var accMock = new Mock <IAccount>(); factoryMock.Setup(f => f.CreateAccount(1111, 2000)).Returns(accMock.Object); repoMock.Setup(r => r.Save(accMock.Object)); var createAccView = new CreateAccountView("fool", consoleMock.Object, repoMock.Object, factoryMock.Object); createAccView.Show(); factoryMock.VerifyAll(); repoMock.VerifyAll(); }