public async Task UpdateAWarehouseStockEntryWhenAStockChangeEventIsReceivedAndItDoesExist() { const string sku = "1234"; const string warehouseId = "FC01"; var existing = new StockQuantityEntity { Sku = sku, WarehouseId = warehouseId, AvailableQty = 2, ReservedQty = 1 }; var message = new StockChangeEventV1 { Sku = sku, WarehouseId = warehouseId, InStockQty = 2, AllocatedQty = 1, ReservedQty = 1 }; Func <StockChangeEventV1, Task> subscriptionMessageHandler = null; AdapterSubstitute <IAzureTopicSubscriber>() .Subscribe(Arg.Do <SubscriptionCreationArgs>(creationArgs => subscriptionMessageHandler = creationArgs.MessageHandler)); AdapterSubstitute <IStockQuantityQuery>().GetSingle(sku, warehouseId).Returns(existing); // act _theSqsMessagingWorker.Start(); await subscriptionMessageHandler(message); // assert await AdapterSubstitute <IStockQuantityCommand>() .Received(1) .Update(Arg.Is <StockQuantityEntity>(arg => arg.WarehouseId == warehouseId && arg.Sku == sku)); }
public async Task ReturnTheDocumentIfItExists() { var existing = new StockQuantityEntity() { Id = Guid.NewGuid(), WarehouseId = "FC01", Sku = "ABCDEF", AvailableQty = 6, ReservedQty = 3 }; var collectionLink = await docDbClient.EnsureCollection(_databaseUri, StockQuantityCollectionName); await docDbClient.DeleteDocuments <StockQuantityEntity>(collectionLink, sqe => sqe.Sku == existing.Sku && sqe.WarehouseId == existing.WarehouseId); await docDbClient.EnsureDocument(collectionLink, existing); var result = await target.GetSingle(existing.Sku, existing.WarehouseId); result.ShouldBeEquivalentTo(existing); }
public void Insert(StockQuantityEntity entity) { throw new System.NotImplementedException(); }
public async Task Update(StockQuantityEntity entity) { throw new System.NotImplementedException(); }