public void UserNotifiedOnFundsLow() { var amount = 1m; withdrawMoney.Execute( TestAccountFactory.Ids.FundsLow, amount); // TODO: Shouldn't be creating a new account here just to get its email var fromAccount = TestAccountFactory.NewFundsLow(); // Ensure that only funds low notification sent NotificationServiceMock.Verify(x => x.NotifyApproachingPayInLimit(It.IsAny <string>()), Times.Never); NotificationServiceMock.Verify(x => x.NotifyFundsLow(fromAccount.User.Email), Times.Once); }
public void ToUserNotifiedOnApproachingPayInLimit() { var amount = 1m; transferMoney.Execute( TestAccountFactory.Ids.DefaultFrom, TestAccountFactory.Ids.ApproachingPayInLimit, amount); // TODO: Shouldn't be creating a new account here just to get its email var fromAccount = TestAccountFactory.NewFundsLow(); // Ensure that only approaching pay in limit notification sent NotificationServiceMock.Verify(x => x.NotifyApproachingPayInLimit(It.IsAny <string>()), Times.Once); NotificationServiceMock.Verify(x => x.NotifyFundsLow(fromAccount.User.Email), Times.Never); }
public virtual void SetUp() { UpdatedAccounts = new Dictionary <Guid, Account>(); AccountRepositoryMock = new Mock <IAccountRepository>(); AccountRepositoryMock .Setup(x => x.GetAccountById(TestAccountFactory.Ids.DefaultFrom)) .Returns(TestAccountFactory.NewDefaultFrom()); AccountRepositoryMock .Setup(x => x.GetAccountById(TestAccountFactory.Ids.DefaultTo)) .Returns(TestAccountFactory.NewDefaultTo()); AccountRepositoryMock .Setup(x => x.GetAccountById(TestAccountFactory.Ids.FundsLow)) .Returns(TestAccountFactory.NewFundsLow()); AccountRepositoryMock .Setup(x => x.GetAccountById(TestAccountFactory.Ids.ApproachingPayInLimit)) .Returns(TestAccountFactory.NewApproachingPayInLimit()); AccountRepositoryMock .Setup(x => x.GetAccountById(TestAccountFactory.Ids.AtPayInLimit)) .Returns(TestAccountFactory.NewAtPayInLimit()); AccountRepositoryMock .Setup(x => x.Update(It.IsAny <Account>())) .Callback <Account>(x => { // Note: this is an assumption based on the fact that we want to be atomic with account updates if (UpdatedAccounts.ContainsKey(x.Id)) { throw new InvalidOperationException("Accounts should only be updated once"); } UpdatedAccounts.Add(x.Id, x); }); NotificationServiceMock = new Mock <INotificationService>(); NotificationServiceMock.Setup(x => x.NotifyFundsLow(It.IsAny <string>())); NotificationServiceMock.Setup(x => x.NotifyApproachingPayInLimit(It.IsAny <string>())); }