public async Task Batch_Filling_In_Progress() { // Arrange var clientId = Guid.NewGuid(); var cashoutId = Guid.NewGuid(); for (var i = 0; i < _countTreshold - 2; ++i) { _batch.AddCashout(new BatchedCashoutValueType(Guid.NewGuid(), Guid.NewGuid(), $"Destination-{i}", 100 * i, i, DateTime.UtcNow)); } // Act var handlingResult = await _handler.Handle ( new AcceptCashoutCommand { BlockchainType = "Bitcoin", BlockchainAssetId = "BTC", AssetId = "LykkeBTC", Amount = 50, ClientId = clientId, OperationId = cashoutId, HotWalletAddress = "HotWallet", ToAddress = "Destination-last" }, _eventsPublisherMock.Object ); // Assert Assert.False(handlingResult.Retry); Assert.Equal(CashoutsBatchState.FillingUp, _batch.State); Assert.Equal(_countTreshold - 1, _batch.Cashouts.Count); Assert.Equal(cashoutId, _batch.Cashouts.Last().CashoutId); _batchRepositoryMock.Verify(x => x.SaveAsync(It.Is <CashoutsBatchAggregate>(p => p.BatchId == _batch.BatchId)), Times.Once); _eventsPublisherMock .Verify ( x => x.PublishEvent ( It.Is <BatchedCashoutStartedEvent>(p => p.BatchId == _batch.BatchId && p.Amount == 50 && p.AssetId == "LykkeBTC" && p.BlockchainAssetId == "BTC" && p.BlockchainType == "Bitcoin" && p.ClientId == clientId && p.HotWalletAddress == "HotWallet" && p.OperationId == cashoutId && p.ToAddress == "Destination-last") ), Times.Once ); _eventsPublisherMock.VerifyNoOtherCalls(); }
public async Task Continue_Waiting_If_Batch_Is_Not_Expired() { // Arrange _batch.AddCashout(new BatchedCashoutValueType(Guid.NewGuid(), Guid.NewGuid(), "Destination", 100, 0, DateTime.UtcNow)); // Act var handlingResult = await _handler.Handle ( new WaitForBatchExpirationCommand { BatchId = _batch.BatchId }, _eventsPublisherMock.Object ); // Assert Assert.True(handlingResult.Retry); Assert.Equal(_expirationMonitoringPeriod, TimeSpan.FromMilliseconds(handlingResult.RetryDelay)); Assert.Equal(CashoutsBatchState.FillingUp, _batch.State); _batchRepositoryMock.Verify(x => x.SaveAsync(It.IsAny <CashoutsBatchAggregate>()), Times.Never); _eventsPublisherMock.Verify(x => x.PublishEvent(It.IsAny <BatchExpiredEvent>()), Times.Never); _eventsPublisherMock.VerifyNoOtherCalls(); }