public async Task GetShouldReturnOkResult()
        {
            // Arrange
            var fakeSql = Substitute.For<IDatabase>();

            var controller = new EventsController(fakeSql);

            // Act
            var result = await controller.Get();

            // Assert
            var viewResult = Assert.IsType<OkNegotiatedContentResult<IEnumerable<EmberEvent>>>(result);
            Assert.NotNull(viewResult);
        }
        public async Task GetShouldReturnConvertedIpAdress()
        {
            // Arrange
            AutomapperConfig.Init();

            var ipAddress = IPAddress.Loopback;

            var modelList = new List<DatabaseEvent>
            {
                new DatabaseEvent
                {
                    //Id = 1,
                    
                    //UserId = Guid.NewGuid(),
                    //UserAgent = "UserAgent",
                    //UserLanguage = "UserLanguage",
                    UserHostAddress = ipAddress.GetAddressBytes(),
                    UserProxyAddress = ipAddress.GetAddressBytes(),

                    //Time = DateTimeOffset.UtcNow,

                    //Referer = "Referer",

                    //Flight = 1,
                    //Destination = 1
                }
            };

            var fakeSql = Substitute.For<IDatabase>();
            fakeSql.QueryAsync<DatabaseEvent>("SELECT * FROM Events")
                   .Returns(Task.FromResult<IEnumerable<DatabaseEvent>>(modelList));

            var controller = new EventsController(fakeSql);

            // Act
            var result = await controller.Get();

            // Assert
            var viewResult = Assert.IsType<OkNegotiatedContentResult<IEnumerable<EmberEvent>>>(result);
            Assert.NotNull(viewResult);
            Assert.True(viewResult.Content.All(a => a.UserHostAddress == ipAddress.ToString()));
            Assert.True(viewResult.Content.All(a => a.UserProxyAddress == ipAddress.ToString()));
        }
        public async Task GetByIdShouldReturnBadRequestErrorMessageResultOnNullFromDatabase()
        {
            // Arrange
            var fakeSql = Substitute.For<IDatabase>();
            fakeSql.ReadAsync<DatabaseEvent>(1)
                   .Returns(Task.FromResult<DatabaseEvent>(null));

            var controller = new EventsController(fakeSql);

            // Act
            var result = await controller.Get(1);

            // Assert
            var viewResult = Assert.IsType<BadRequestErrorMessageResult>(result);
            Assert.NotNull(viewResult);
        }
        public async Task GetByFlightShouldReturnBadRequestErrorMessageResultOnEmptyFlight()
        {
            // Arrange
            var fakeSql = Substitute.For<IDatabase>();

            var controller = new EventsController(fakeSql);

            // Act
            var result = await controller.Get(string.Empty);

            // Assert
            var viewResult = Assert.IsType<BadRequestErrorMessageResult>(result);
            Assert.NotNull(viewResult);
        }
        public async Task GetByIdShouldReturnOkResult()
        {
            // Arrange
            AutomapperConfig.Init();

            var fakeSql = Substitute.For<IDatabase>();
            fakeSql.ReadAsync<DatabaseEvent>(1)
                   .Returns(Task.FromResult(new DatabaseEvent()));

            var controller = new EventsController(fakeSql);

            // Act
            var result = await controller.Get(1);

            // Assert
            var viewResult = Assert.IsType<OkNegotiatedContentResult<EmberEvent>>(result);
            Assert.NotNull(viewResult);
        }