public async Task IfNotEnoughBalance_ShouldFailWithdraw() { // arrange await TestsHelpers.EnsureAccountState(needBalance : 123); (await TestsHelpers.GetAccount()).Balance.Should().Be(123); // act var operationId = await ClientUtil.AccountsApi.BeginWithdraw(TestsHelpers.ClientId, TestsHelpers.AccountId, new AccountChargeManuallyRequest { AmountDelta = 124, Reason = "intergational tests: withdraw", }); var eventTask = await Task.WhenAny( RabbitUtil.WaitForCqrsMessage <WithdrawalSucceededEvent>(m => m.OperationId == operationId), RabbitUtil.WaitForCqrsMessage <WithdrawalFailedEvent>(m => m.OperationId == operationId)); eventTask.Should().BeOfType <Task <WithdrawalFailedEvent> >(); // assert (await TestsHelpers.GetAccount()).Balance.Should().Be(123); }
public async Task Always_ShouldUpdateBalance(decimal delta) { // arrange await TestsHelpers.EnsureAccountState(); // act await TestsHelpers.ChargeManually(delta); // assert (await TestsHelpers.GetAccount()).Balance.Should().Be(0 + delta); }
public async Task EnsureAccountState_Always_ShouldFixAccount() { // arrange // act var result = await TestsHelpers.EnsureAccountState(needBalance : 13); // assert var account = await TestsHelpers.GetAccount(); account.Should().BeEquivalentTo(new { ClientId = TestsHelpers.ClientId, Id = TestsHelpers.AccountId, Balance = 13, IsDisabled = false, }, o => o.ExcludingMissingMembers()); result.Should().BeEquivalentTo(account); }
public async Task Always_ShouldUpdateBalance(decimal delta) { // arrange await TestsHelpers.EnsureAccountState(); var operationId = Guid.NewGuid().ToString(); /* * // act * //todo use specific command * /*CqrsUtil.SendCommandToAccountManagement( * new BeginClosePositionBalanceUpdateCommand(TestsHelpers.ClientId, TestsHelpers.AccountId, delta, * operationId, "IntegrationalTests", "Always_ShouldUpdateBalance")); * * await RabbitUtil.WaitForCqrsMessage<AccountBalanceChangedEvent>(m => m.OperationId == operationId); * * // assert * (await TestsHelpers.GetAccount()).Balance.Should().Be(0 + delta); */ }
public async Task IfEnoughBalance_ShouldWithdraw() { // arrange await TestsHelpers.EnsureAccountState(needBalance : 123); // act var operationId = await ClientUtil.AccountsApi.BeginWithdraw(TestsHelpers.ClientId, TestsHelpers.AccountId, new AccountChargeManuallyRequest { AmountDelta = 123, Reason = "intergational tests: withdraw", }); var messagesReceivedTask = Task.WhenAll( RabbitUtil.WaitForCqrsMessage <AccountBalanceChangedEvent>(m => m.OperationId == operationId), RabbitUtil.WaitForCqrsMessage <WithdrawalSucceededEvent>(m => m.OperationId == operationId)); await messagesReceivedTask; // assert (await TestsHelpers.GetAccount()).Balance.Should().Be(0); }