Пример #1
0
        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);
        }
Пример #2
0
 protected void StockUpItem()
 {
     executor
     .Do(() => messagePublisher.Publish(new ProductReceivedFromSupplier {
         ProductId = productId, NumberOfItems = 1
     }))
     .Return()
     .When(ConfirmationMatcher <ProductReceivedFromSupplier> .Any(consumerServiceName).WaitFor(TimeSpan.FromSeconds(5)));
 }
Пример #3
0
        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);
        }
Пример #4
0
        public void CrmProcessesOurSpecificProductPurchasedEvent()
        {
            StockUpItem();

            executor
            .Do(() => messagePublisher.Publish(new PurchaseProduct {
                ProductId = productId, CustomerId = customerId
            }))
            .Return()
            .When(purchaseProductConfirmation,
                  productPurchased,
                  ConfirmationMatcher <ProductPurchased> .Single(productPurchased, consumerServiceName).WaitFor(TimeSpan.FromSeconds(5)));
        }