public void Start_WhenCalled_ShouldBroadCastAllExceptions()
        {
            DroneActions.EditSettings<DroneSettings>(x =>
                                                        {
                                                            x.Identifier = "drone1";
                                                            x.BaseUrl = "http://192.168.1.1:2589";
                                                            x.Domain = "example.com";
                                                            x.StoreHostname = DefaultHostUrl;
                                                        });

            DroneActions.EditSettings<ApiCallsSettings>(x =>
                                                            {
                                                                x.ApiBaseUri = DefaultBaseUrl;
                                                            });

            Api.ListenToApiCall<ServiceEndpoints.Drones.RegisterDrone>();

            DroneActions.Store(new DroneExceptionLogEntry { component = "c", message = "message", time = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToString(), exception = "exception" });

            var task = new BroadcastDroneToServiceTask();
            _scheduledTaskManager.AddAndStart(task);

            Api.AssertApiCalled<ServiceEndpoints.Drones.RegisterDrone>(x => x.Exceptions[0].Component == "c" &&
                                                                            x.Exceptions[0].Exception == "exception" &&
                                                                            x.Exceptions[0].Message == "message" &&
                                                                            x.Exceptions[0].Time == new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToString()
                );
        }
        public void Start_WhenCalled_ShouldContactTheMasterServiceAndRegisterTheDrone()
        {
            DroneActions.EditSettings<DroneSettings>(x =>
                                                        {
                                                            x.Identifier = "drone1";
                                                            x.BaseUrl = "http://192.168.1.1:2589";
                                                            x.Domain = "example.com";
                                                        });

            DroneActions.EditSettings<ApiCallsSettings>(x =>
                                                            {
                                                                x.ApiBaseUri = DefaultBaseUrl;
                                                            });

            Api.ListenToApiCall<ServiceEndpoints.Drones.RegisterDrone>();

            var task = new BroadcastDroneToServiceTask();
            _scheduledTaskManager.AddAndStart(task);

            Api.AssertApiCalled<ServiceEndpoints.Drones.RegisterDrone>(x =>
                                                            x.Identifier == "drone1" &&
                                                            x.BaseUrl == "http://192.168.1.1:2589" &&
                                                            x.Domain == "example.com"
                );
        }
        public void Start_WhenCalled_ShouldPostTheReputationToTheMaster()
        {
            DroneActions.EditSettings<DroneSettings>(x =>
                                                        {
                                                            x.Identifier = "drone1";
                                                            x.BaseUrl = "http://192.168.1.1:2589";
                                                            x.Domain = "example.com";
                                                            x.StoreHostname = DefaultHostUrl;
                                                        });

            DroneActions.EditSettings<ApiCallsSettings>(x =>
                                                            {
                                                                x.ApiBaseUri = DefaultBaseUrl;
                                                            });

            Api.ListenToApiCall<ServiceEndpoints.Drones.RegisterDrone>();

            DroneActions.Store(new IpReputation
                {
                    BlockingHistory = new Dictionary<string, List<DateTime>> { { "gmail", new List<DateTime> { new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc) } } },
                    ResumingHistory = new Dictionary<string, List<DateTime>> { { "gmail", new List<DateTime> { new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc) } } }
                });

            var task = new BroadcastDroneToServiceTask();
            _scheduledTaskManager.AddAndStart(task);

            Api.AssertApiCalled<ServiceEndpoints.Drones.RegisterDrone>(x =>
                                                                       x.IpReputation.BlockingHistory["gmail"][0] == new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc) &&
                                                                       x.IpReputation.ResumingHistory["gmail"][0] == new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc)
                );
        }