Exemple #1
0
        public void TransportFailureHandlingTest()
        {
            var resolver = MockTransportResolver();

            using (var engine = new MessagingEngine(new LogToConsole(), resolver, new InMemoryTransportFactory()))
            {
                engine.SerializationManager.RegisterSerializer(SerializationFormat.Json, typeof(string), new FakeStringSerializer());
                int failureWasReportedCount = 0;
                engine.SubscribeOnTransportEvents((transportId, @event) => failureWasReportedCount++);

                //need for transportManager to start tracking transport failures for these ids
                engine.TransportManager.GetMessagingSession(TransportConstants.TRANSPORT_ID1, "test");
                engine.TransportManager.GetMessagingSession(TransportConstants.TRANSPORT_ID2, "test");

                engine.TransportManager.ProcessTransportFailure(
                    new TransportInfo(TransportConstants.BROKER,
                                      TransportConstants.USERNAME,
                                      TransportConstants.PASSWORD, "MachineName", "InMemory"));
                Assert.That(failureWasReportedCount, Is.GreaterThan(0), "Failure was not reported");
                Assert.That(failureWasReportedCount, Is.EqualTo(2), "Failure was not reported for all ids");
            }
        }