static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Not all command line arguments provided.\nPlease provide accessCode and TeamId.\nPress any key to continue..."); Console.ReadKey(); return; } var serverUrl = args[0]; var accessCode = args[1]; var teamName = args[2]; IConnectionFactory connectionFactory = new ConnectionFactory() { HostName = serverUrl }; IRabbitClient rabbitClient = new RabbitClient(teamName, accessCode, new ChannelRegistry(), new QueueRegistry(), connectionFactory); IPilotApi pilotApi = new PilotApi(rabbitClient, accessCode, teamName); IPilot pilot = new Pilot.Pilot(pilotApi); pilotApi.ConnectToRabbitMq(); pilot.SubscribeToAllChannels(); Console.ReadKey(); }
public void GivenPilotApiAndRabbitClient_WhenHostNameIsOkAndServerIsRunning_ThenConnectionCreationIsCalled() { var rabbitClient = new RabbitClient("Team-0", "Team-0", new ChannelRegistry(), new QueueRegistry(), connectionFactoryMock.Object); rabbitClient.Log = logMock.Object; var pilotApi = new PilotApi(rabbitClient, "Team-0", "Team-0"); pilotApi.ConnectToRabbitMq(); connectionFactoryMock.Verify(connectionFactory => connectionFactory.CreateConnection()); }
public void GivenPilotApiAndRabbitClient_WhenConnectionIsCreatedAndSubscribeCalled_ThenSubscriptionIsBeingCreated() { var connectionFactory = new ConnectionFactory() { HostName = "localhost" }; var rabbitClient = new RabbitClient("Team-0", "Team-0", channelRegistryMock.Object, queueRegistryMock.Object, connectionFactory); rabbitClient.Log = logMock.Object; var pilotApi = new PilotApi(rabbitClient, "Team-0", "Team-0"); pilotApi.ConnectToRabbitMq(); pilotApi.SubscribeOnSensor((msg) => { }); logMock.Verify(mock => mock.Info("Subscribed to sensor messages.")); }
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)); }