Exemple #1
0
        void VerifySend <S, D>(Action <S> sourceConfig, Action <D> destinationConfig)
            where S : IEndpointConfiguration
            where D : IEndpointConfiguration
        {
            using (var source = EndpointFacadeBuilder.CreateAndConfigure(sourceEndpoint, sourceConfig))
                using (var destination = EndpointFacadeBuilder.CreateAndConfigure(destinationEndpoint, destinationConfig))
                {
                    var messageId = Guid.NewGuid();

                    source.SendCommand(messageId);

                    // ReSharper disable once AccessToDisposedClosure
                    AssertEx.WaitUntilIsTrue(() => destination.ReceivedMessageIds.Any(mi => mi == messageId));
                }
        }
        void VerifyRoundtrip <S, D>(Action <S> initiatorConfig, Action <D> replierConfig)
            where S : IEndpointConfiguration
            where D : IEndpointConfiguration
        {
            using (var source = EndpointFacadeBuilder.CreateAndConfigure(sourceEndpoint, initiatorConfig))
                using (EndpointFacadeBuilder.CreateAndConfigure(destinationEndpoint, replierConfig))
                {
                    var requestId = Guid.NewGuid();

                    source.SendRequest(requestId);

                    // ReSharper disable once AccessToDisposedClosure
                    AssertEx.WaitUntilIsTrue(() => source.ReceivedResponseIds.Any(responseId => responseId == requestId));
                }
        }
        void VerifyPublish <S, D>(Action <S> publisherConfig, Action <D> subscriberConfig)
            where S : IEndpointConfiguration
            where D : IEndpointConfiguration
        {
            using (var publisherFacade = EndpointFacadeBuilder.CreateAndConfigure(publisher, publisherConfig))
                using (var subscriberFacade = EndpointFacadeBuilder.CreateAndConfigure(subscriber, subscriberConfig))
                {
                    // ReSharper disable once AccessToDisposedClosure
                    AssertEx.WaitUntilIsTrue(() => publisherFacade.NumberOfSubscriptions > 0);

                    var eventId = Guid.NewGuid();

                    publisherFacade.PublishEvent(eventId);

                    // ReSharper disable once AccessToDisposedClosure
                    AssertEx.WaitUntilIsTrue(() => subscriberFacade.ReceivedEventIds.Any(ei => ei == eventId));
                }
        }
Exemple #4
0
        void VerifyRoundtrip <S, D>(Action <S> sourceConfig, Action <S> competingSourceConfig, Action <D> destinationConfig)
            where S : IEndpointConfiguration
            where D : IEndpointConfiguration
        {
            using (var source = EndpointFacadeBuilder.CreateAndConfigure(sourceEndpoint, sourceConfig))
                using (EndpointFacadeBuilder.CreateAndConfigure(competingEndpoint, competingSourceConfig))
                    using (EndpointFacadeBuilder.CreateAndConfigure(destinationEndpoint, destinationConfig))
                    {
                        var firstValue = new Random().Next(1000);
                        var values     = Enumerable.Range(0, 5).Select(i => firstValue + i).ToArray();

                        foreach (var value in values)
                        {
                            source.SendAndCallbackForInt(value);
                        }

                        //Wait till all five responses arrive at the initiator.

                        // ReSharper disable once AccessToDisposedClosure
                        AssertEx.WaitUntilIsTrue(() => values.All(value => source.ReceivedIntCallbacks.Contains(value)));
                        Console.WriteLine("Done");
                    }
        }