예제 #1
0
        public async Task <IActionResult> OnPost()
        {
            using (var db = new postgresContext())
            {
                VehiclesController vehicle = new VehiclesController(db);
                await vehicle.PostVehicle(Vehicle);

                return(RedirectToPage("/Vehicle/Index"));
            }
        }
예제 #2
0
        public async Task aPostTruck0()
        {
            ActionResult <Vehicle> actionresult = await _controller.PostVehicle(testTrucks[0]);

            if (actionresult.Result is BadRequestObjectResult)
            {
                BadRequestObjectResult result = actionresult.Result as BadRequestObjectResult;
                Assert.Fail(result.Value.ToString());
            }
            else
            {
                CreatedAtActionResult result = actionresult.Result as CreatedAtActionResult;
                Vehicle truck = result.Value as Vehicle;
                if (truck.Name == testTrucks[0].Name && truck.Make == testTrucks[0].Make)
                {
                    Assert.Pass();
                }
                else
                {
                    Assert.Fail();
                }
            }
        }