public async Task PostShouldReturnOkResultWithModelDataUpdated()
        {
            // Arrange
            var model = new Flight();

            var datetimeoffset = DateTimeOffset.UtcNow;
            Mock.Arrange(() => DateTimeOffset.UtcNow).Returns(datetimeoffset);

            var userid = Guid.NewGuid().ToString();
            var fakeContext = Mock.Create<HttpContext>(Constructor.Mocked);
            Mock.Arrange(() => HttpContext.Current).Returns(fakeContext);
            Mock.Arrange(() => HttpContext.Current.User.Identity.GetUserId()).Returns(userid);

            var fakeSql = Substitute.For<IDatabase>();
            fakeSql.CreateAsync(model).Returns(Task.FromResult(1));

            var controller = new FlightsController(fakeSql);

            // Act
            var result = await controller.Post(model);

            // Assert
            var viewResult = Assert.IsType<OkNegotiatedContentResult<Flight>>(result);
            Assert.Equal(viewResult.Content.UserId, userid);
            Assert.Equal(viewResult.Content.AddedDate, datetimeoffset);
            Assert.Equal(viewResult.Content.ModifiedDate, null);
        }
        public async Task PostShouldReturnOkResultWhenResultGreaterThanOne()
        {
            // Arrange
            var model = new Flight();

            var fakeContext = Mock.Create<HttpContext>(Constructor.Mocked);
            Mock.Arrange(() => HttpContext.Current).Returns(fakeContext);

            var fakeSql = Substitute.For<IDatabase>();
            fakeSql.CreateAsync(model).Returns(Task.FromResult(1));

            var controller = new FlightsController(fakeSql);

            // Act
            var result = await controller.Post(model);

            // Assert
            var viewResult = Assert.IsType<OkNegotiatedContentResult<Flight>>(result);
            Assert.NotNull(viewResult);
        }
        public async Task PostShouldReturnInvalidModelStateResultWhenInvalidModel()
        {
            // Arrange
            var model = new Flight();

            var fakeSql = Substitute.For<IDatabase>();
            fakeSql.CreateAsync(model).Returns(Task.FromResult(1));

            var controller = new FlightsController(fakeSql)
            {
                Configuration = new HttpConfiguration()
            };
            controller.ModelState.AddModelError("FakeError", "This is a Fake Error!");

            // Act
            var result = await controller.Post(model);

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