public void MakeSureOnlyASingleProductPurchasedEventOccurs() { var productPurchased = MessageMatcher <ProductPurchased> .Single(msg => msg.CustomerId == customerId && msg.ProductId == productId); //oops two stock services are processing orders now! bus.Consume <PurchaseProduct>(consumerServiceName, new Stock(messagePublisher)); StockUpItem(); executor .Try(() => messagePublisher.Publish(new PurchaseProduct { ProductId = productId, CustomerId = customerId })) .Return() .When(ConfirmationMatcher <PurchaseProduct> .Any(consumerServiceName), productPurchased, MessageMatcher <CustomerBilled> .Any(msg => msg.CustomerId == customerId && msg.ProductId == productId).WaitFor(TimeSpan.FromSeconds(45))); Assert.That(productPurchased.IsMatched); var asserter = new Asserter(); productPurchased.AssertOk(asserter); Assert.IsFalse(asserter.IsOk); Console.WriteLine(asserter); }
public virtual void Setup() { customerBilled = MessageMatcher <CustomerBilled> .Any(msg => msg.CustomerId == customerId && msg.ProductId == productId); receiptWasSent = MessageMatcher <ReceiptWasSent> .Any(msg => msg.CustomerId == customerId && msg.ProductId == productId); productPurchased = MessageMatcher <ProductPurchased> .Any(msg => msg.CustomerId == customerId && msg.ProductId == productId); purchaseProductConfirmation = ConfirmationMatcher <PurchaseProduct> .Any(consumerServiceName); }