public void Put([Values(1000961)] int id) { _controller.Request.Method = HttpMethod.Put; var actual = _controller.Put(id, new BrandDto { Name = "Test_002", Description = "Description_002", Enabled = true, EnglishName = "EnglishName_002", Id = id, Supplier = new SupplierDto { Id = 23, Name = "Test修改关系只用ID即可" }, Sections = new List <SectionDto> { new SectionDto { Id = 877, Name = "王晓华那个 应该添加不进去" }, new SectionDto { Id = 871, Name = "王晓华那个 应该添加不进去,这个可以有" } } }, 0) as OkNegotiatedContentResult <BrandDto>; Assert.IsNotNull(actual); }
public async void Task_UpdateBrand_Return_NotFound() { var controller = new BrandController(context); var id = 10; var brand = new Brand() { BrandId = 6, BrandName = "Reebok", BrandDescription = "Reebok's Desc" }; var data = await controller.Put(id, brand); Assert.IsType <NotFoundResult>(data); }
public async void Task_UpdateBrand_Return_BadResult() { var controller = new BrandController(context); int?id = null; var brand = new Brand() { BrandId = 6, BrandName = "Reebok", BrandDescription = "Reebok's Desc" }; var data = await controller.Put(id, brand); Assert.IsType <BadRequestResult>(data); }
public async void Task_UpdateBrand_Return_OkResult() { var controller = new BrandController(context); int BrandId = 6; var brand = new Brand() { BrandId = 6, BrandName = "Reebok", BrandDescription = "Reebok's Desc" }; var data = await controller.Put(BrandId, brand); Assert.IsType <OkObjectResult>(data); }
public static async Task UpdateBrandName(BrandId id, string name) { var connectionString = ConnectivityService.GetConnectionString("TEMP"); var context = new SplurgeStopDbContext(connectionString); var repository = new BrandRepository(context); var unitOfWork = new EfCoreUnitOfWork(context); var service = new BrandService(repository, unitOfWork); var brandController = new BrandController(service); var updateCommand = new Commands.SetBrandName { Id = id, Name = name }; await brandController.Put(updateCommand); }