예제 #1
0
        public void GivenRabbitClient_WhenPowerMessageSent_ThenRabbitReceivesAMessage()
        {
            var pilotApi = new PilotApi(rabbitClientMock.Object, "Team-0", "Team-0");

            pilotApi.SetPower(100);

            rabbitClientMock.Verify(mock => mock.Publish(It.IsAny <string>(), RoutingKeyNames.Power, It.IsAny <string>()));
        }
예제 #2
0
        public void GivenPilotApiAndRabbitClient_WhenConnectionIsCreatedAndPublishCalled_ThenChannelExchangeDeclareIsCalled()
        {
            ChannelRegistry channelRegistry;
            var             connectionFactory = new ConnectionFactory()
            {
                HostName = "localhost"
            };
            var rabbitClient = new RabbitClient("Team-0", "Team-0", channelRegistry = new ChannelRegistry(), new QueueRegistry(), connectionFactory);

            rabbitClient.Log = logMock.Object;

            var pilotApi = new PilotApi(rabbitClient, "Team-0", "Team-0");

            pilotApi.ConnectToRabbitMq();
            channelRegistry.Channels["Team-0" + "-" + RoutingKeyNames.Power] = channelMock.Object;

            pilotApi.SetPower(120);

            channelMock.Verify(mock => mock.ExchangeDeclare(It.IsAny <string>(), "direct", false, false, null));
        }