public async Task When_account_replenished_Then_amount_should_be_increased() { ReplenishAccountByCardCommand command; Money initialAmount; var scenario = AggregateScenario.New <Account, AccountCommandsHandler>(); await scenario.Given(new AccountCreated(scenario.Aggregate.Id, Guid.NewGuid(), 123), new AccountReplenish(scenario.Aggregate.Id, Guid.NewGuid(), initialAmount = new Money(100))) .When(command = new ReplenishAccountByCardCommand(scenario.Aggregate.Id, new Money(12), "xxx123")) .Then(new AccountReplenish(scenario.Aggregate.Id, command.Id, command.Amount)) .Run() .Check(); Assert.Equal(initialAmount + command.Amount, scenario.Aggregate.Amount); }
public void Given_business_with_money() { var registerNewBusinessCommand = new RegisterNewBusinessCommand(_businessId, "test business", _accountId); ExecuteAndWaitFor <BusinessCreatedEvent>(registerNewBusinessCommand); var createAccountCommand = new CreateAccountCommand(_accountId, _businessId); ExecuteAndWaitFor <BusinessBalanceCreatedProjectedNotification>(createAccountCommand); var replenishAccountByCardCommand = new ReplenishAccountByCardCommand(_accountId, _amount, null); ExecuteAndWaitFor <AccountBalanceReplenishEvent>(replenishAccountByCardCommand); var orderSubscriptionCommand = new OrderSubscriptionCommand(_businessId, VIPSubscription.ID, _subscriptionId); ExecuteAndWaitFor <SubscriptionOrderCompletedEvent>(orderSubscriptionCommand); Thread.Sleep(2000); //to build up read model }