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)); }
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); }
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)); }