예제 #1
0
        public void CreateShouldMapCorrectAction()
        {
            var    flightRequestModel = TestObjectFactoryDataTransferModels.GetValidFlightRequestModel();
            string jsonContent        = JsonConvert.SerializeObject(flightRequestModel);

            MyWebApi
            .Routes()
            .ShouldMap(CREATE_PATH)
            .WithJsonContent(jsonContent)
            .And()
            .WithHttpMethod(HttpMethod.Post)
            .To <FlightsController>(f => f.Create(flightRequestModel));
        }
예제 #2
0
        public void CreateShouldReturnOkResultWithId()
        {
            this.flightsController.Configuration = new HttpConfiguration();

            var validModel = TestObjectFactoryDataTransferModels.GetValidFlightRequestModel();

            this.flightsController.Validate(validModel);

            var result   = this.flightsController.Create(validModel);
            var okResult = result as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(okResult);
            Assert.AreEqual(Constants.ENTITY_VALID_ID, okResult.Content);
        }
예제 #3
0
        public void CreateShouldThrowExceptionWithRouteDoesNotExistWhenHttpMethodIsInvalid()
        {
            var    flightRequestModel = TestObjectFactoryDataTransferModels.GetValidFlightRequestModel();
            string jsonContent        = JsonConvert.SerializeObject(flightRequestModel);

            var invalidHttpMethod = HttpMethod.Get;

            MyWebApi
            .Routes()
            .ShouldMap(CREATE_PATH)
            .WithJsonContent(jsonContent)
            .And()
            .WithHttpMethod(invalidHttpMethod)
            .To <FlightsController>(f => f.Create(flightRequestModel));
        }