public WaitForDeliveriesAndFailures ( int deliveryCount, int failureCount, System.TimeSpan timeout, System.Action inner ) : void | ||
deliveryCount | int | |
failureCount | int | |
timeout | System.TimeSpan | |
inner | System.Action | |
return | void |
public void Failure_Queue_Receives_Messages_When_Retries_Maxed() { using (var serviceBusRuntime = Create.MsmqRuntime <IContract>()) { ServiceBusTest tester = new ServiceBusTest(serviceBusRuntime); tester.OnlyRetryOnce(); string message = "Publish this message"; ContractImplementation ci = new ContractImplementation(); ci.SetFailCount(3); tester.AddTestListener(); tester.AddTestSubscription(ci, new PassThroughMessageFilter()); tester.WaitForDeliveriesAndFailures(1, 3, TimeSpan.FromSeconds(10), () => { serviceBusRuntime.PublishOneWay(new PublishRequest(typeof(IContract), "PublishThis", message)); }); Assert.AreEqual(0, ci.PublishedCount); MessageDelivery delivery = serviceBusRuntime.ServiceLocator.GetInstance <QueuedDeliveryCore>().FailureQueue.Dequeue(TimeSpan.FromSeconds(1)); Assert.IsNotNull(delivery); tester.VerifyQueuesEmpty(); Assert.AreEqual(3, ((IEnumerable <string>)delivery.Context[MessageDelivery.Exceptions]).Count()); } }
public void Failure_Queue_Receives_Messages_When_Retries_Maxed() { using (var serviceBusRuntime = Create.MsmqRuntime<IContract>()) { ServiceBusTest tester = new ServiceBusTest(serviceBusRuntime); tester.OnlyRetryOnce(); string message = "Publish this message"; ContractImplementation ci = new ContractImplementation(); ci.SetFailCount(3); tester.AddTestListener(); tester.AddTestSubscription(ci, new PassThroughMessageFilter()); tester.WaitForDeliveriesAndFailures(1, 3, TimeSpan.FromSeconds(10), () => { serviceBusRuntime.PublishOneWay(new PublishRequest(typeof(IContract), "PublishThis", message)); }); Assert.AreEqual(0, ci.PublishedCount); MessageDelivery delivery = serviceBusRuntime.ServiceLocator.GetInstance<QueuedDeliveryCore>().FailureQueue.Dequeue(TimeSpan.FromSeconds(1)); Assert.IsNotNull(delivery); tester.VerifyQueuesEmpty(); Assert.AreEqual(3, ((IEnumerable<string>)delivery.Context[MessageDelivery.Exceptions]).Count()); } }