Пример #1
0
        public void PostsLocation()
        {
            var vehicleModelController = new VehicleModelsController(vehicleServiceModel.Object, _vehicleServiceMake, _mapper);
            var config = new HttpConfiguration();

            var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/");

            IHttpRoute route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");

            HttpRouteData routeData = new HttpRouteData(route, new HttpRouteValueDictionary
            {
                { "controller", "posts" }
            });

            vehicleModelController.ControllerContext = new HttpControllerContext(config, routeData, request);

            request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;

            request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData;

            vehicleModelController.Request = request;

            VehicleModel vehicleModel = new VehicleModel()
            {
                Id = modelId
            };

            vehicleServiceModel.Should().Equals(HttpStatusCode.Created);
            vehicleServiceModel.Should().NotBeNull();
        }
Пример #2
0
        public async Task GetById()
        {
            var vehicleModelController = new VehicleModelsController(vehicleServiceModel.Object, _vehicleServiceMake, _mapper);
            await vehicleModelController.GetVehicleModel(modelId);

            vehicleServiceModel.Should().NotBeNull();
            vehicleServiceModel.Should().Equals(modelId);
        }