Пример #1
0
        public void Establish()
        {
            var dispatcher = A.Fake <IDispatcher>();

            s_firstConsumer = A.Fake <IAmAConsumer>();

            A.CallTo(() => s_firstConsumer.Name).Returns(new ConnectionName(TEST_FIRST_CONNECTION_NAME));
            A.CallTo(() => s_firstConsumer.State).Returns(ConsumerState.Open);

            s_secondConsumer = A.Fake <IAmAConsumer>();
            A.CallTo(() => s_secondConsumer.Name).Returns(new ConnectionName(TEST_SECOND_CONNECTION_NAME));
            A.CallTo(() => s_secondConsumer.State).Returns(ConsumerState.Shut);

            A.CallTo(() => dispatcher.Consumers).Returns(new List <IAmAConsumer>()
            {
                s_firstConsumer, s_secondConsumer
            });

            var hostName = new HostName(Environment.MachineName + "." + System.Reflection.Assembly.GetEntryAssembly().FullName);

            A.CallTo(() => dispatcher.HostName).Returns(hostName);
            s_hostName = hostName;

            s_heartbeatRequest = new HeartbeatRequest(new ReplyAddress(TEST_ROUTING_KEY, s_CorrelationId));

            s_handler = new HeartbeatRequestCommandHandler(s_spyCommandProcessor, dispatcher);
        }
Пример #2
0
        public HeartbeatMessageTests()
        {
            var dispatcher     = A.Fake <IDispatcher>();
            var firstConsumer  = A.Fake <IAmAConsumer>();
            var secondConsumer = A.Fake <IAmAConsumer>();

            A.CallTo(() => firstConsumer.Name).Returns(new ConsumerName(TEST_FIRST_CONNECTION_NAME));
            A.CallTo(() => firstConsumer.State).Returns(ConsumerState.Open);

            A.CallTo(() => secondConsumer.Name).Returns(new ConsumerName(TEST_SECOND_CONNECTION_NAME));
            A.CallTo(() => secondConsumer.State).Returns(ConsumerState.Shut);

            A.CallTo(() => dispatcher.Consumers).Returns(new List <IAmAConsumer> {
                firstConsumer, secondConsumer
            });

            var hostName = new HostName($"{Environment.MachineName}.{Assembly.GetEntryAssembly().FullName}");

            A.CallTo(() => dispatcher.HostName).Returns(hostName);
            _hostName = hostName;

            _heartbeatRequest = new HeartbeatRequest(new ReplyAddress(TEST_ROUTING_KEY, _correlationId));
            _handler          = new HeartbeatRequestCommandHandler(_spyCommandProcessor, dispatcher);
        }