public void AccountCreatedSerialisationRoundtripHasAllFields() { const string AccountName = "Account name"; var offBudgetId = BudgetId.OffBudgetId; var accountCreated = new AddedAccount(AccountName, offBudgetId); var roundtripped = this.SerialisationRoundtrip(accountCreated); Assert.AreNotSame(accountCreated, roundtripped); Assert.AreEqual(accountCreated.Name, roundtripped.Name); Assert.AreEqual(accountCreated.Budget, roundtripped.Budget); this.AssertDomainEventPropertiesAreEqual(accountCreated, roundtripped); }
/// <summary> /// Account created event handler /// </summary> /// <param name="e">Account created event</param> public void Handle(AddedAccount e) { var accountList = this.GetAccountListForBudget(e.Budget); var account = accountList.FirstOrDefault(x => e.AccountId.Equals(x.Id)); if (account == null) { account = new AccountListItem(e.AccountId, e.Name, this.commandBus); this.accountListItemRepository.Save(account); accountList.Add(account); } account.SetName(e.Name); this.accountListRepository.Save(e.Budget, accountList); }
/// <summary> /// Handles <see cref="AddedAccount"/> events /// </summary> /// <param name="e">Event to handle</param> private void When(AddedAccount e) { this.Name = e.Name; }