private static BankAccount SetupAccount() { var accountId = Guid.NewGuid(); var card1Id = Guid.NewGuid(); var card2Id = Guid.NewGuid(); var account = new BankAccount(accountId, 1000); account.AddDebitCard(card1Id, "123-456"); account.AddDebitCard(card2Id, "987-654"); account.SwipeDebitCard(card1Id, "Amazon", 35); account.SwipeDebitCard(card2Id, "Grocery store", 120); account.SwipeDebitCard(card1Id, "Gas station", 45); return account; }
public void Entities_Are_Build_From_History_Replay() { // Create an account and manipulate it to get a // history of events var events = SetupAccount().AppliedEvents; var account = new BankAccount(); // Replaying those events on a new account should yield the // same state. account.ReplayEvents(events); Assert.AreEqual(200, account.GetTotalCardTransactions()); Assert.AreEqual(6, account.Version); Assert.AreEqual(0, account.AppliedEvents.Count); }