コード例 #1
0
ファイル: ControllerTest.cs プロジェクト: HDMI2/CarAPI
        public async void Car_GetAll()
        {
            //https://asp.net-hacker.rocks/2017/09/27/testing-aspnetcore.html

            CarRepository carRepository = new CarRepository();
            var controller = new CarWebApi.Controllers.CarController(carRepository);
            var result = await controller.GetAllCars();
        }
コード例 #2
0
ファイル: ControllerTest.cs プロジェクト: HDMI2/CarAPI
        public async void Car_Post()
        {
            //https://asp.net-hacker.rocks/2017/09/27/testing-aspnetcore.html

            CarRepository carRepository = new CarRepository();
            var controller = new CarWebApi.Controllers.CarController(carRepository);
            Car car = new Car() { ModelName = "Name", YearOfConstruction = 2000, BrandName = BrandNames.BMW };
            var result = await controller.Post(car);


        }
コード例 #3
0
ファイル: ControllerTest.cs プロジェクト: HDMI2/CarAPI
        public async void Car_Delete_Last()
        {
            //https://asp.net-hacker.rocks/2017/09/27/testing-aspnetcore.html

            CarRepository carRepository = new CarRepository();
            var controller = new CarWebApi.Controllers.CarController(carRepository);
            List<Car> cars = await controller.GetAllCars() as List<Car>;

            Assert.NotEmpty(cars);

            int id = (from c in cars
                      //where c.Id > 100000
                     select c).Max(c => c.Id);
            var result = await controller.Delete(id);
            await carRepository.SaveAll();
        }