public async Task GetAllBrands_ShouldReturnList() { // Act var response = await Client.GetAsync("api/brands"); await response.Content.ReadAsStringAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var controller = new BrandsController(_brandRepository); var result = await controller.Get(); Assert.True(result.Count > 0); }
public void GetAllBrands_ShouldReturnAllBrands() { //Arrange var testBrands = BrandBuilderBuilder.GetTestBrands(); var mock = new Mock <IBrandService>(); //Act mock.Setup(p => p.Get()).Returns(testBrands); var controller = new BrandsController(mock.Object); var result = controller.Get() as OkObjectResult; //Assert Assert.IsNotNull(result); Assert.AreEqual(200, result.StatusCode); }
public void Get_ShouldReturnCorrectBrand() { //Arrange Brand testBrand = new Brand(); testBrand = BrandBuilderBuilder.GetTestBrand(); var mock = new Mock <IBrandService>(); var controller = new BrandsController(mock.Object); //Act mock.Setup(p => p.Get(1)).Returns(testBrand); var result = controller.Get(1) as OkObjectResult; //Assert Assert.IsNotNull(result); Assert.AreEqual(testBrand, result.Value); }
public async Task BrandsController_Get_Success() { var brand = new BrandCreateRequest { Name = "Test brand3" }; var controller = new BrandsController(_fixture.BrandService); var createResult = await controller.Post(brand); var createResponse = GetResponse <BrandCreateResponse>(createResult); Assert.Equal(brand.Name, createResponse.Name); var getResult = await controller.Get(createResponse.Id); var brandVm = GetResponse <BrandVm>(getResult); Assert.Equal(createResponse.Id, brandVm.Id); Assert.Equal(brand.Name, brandVm.Name); }
public async Task BrandsController_Delete_Success() { var createRequest = new BrandCreateRequest { Name = "Test brand6" }; var controller = new BrandsController(_fixture.BrandService); var createResult = await controller.Post(createRequest); var createResponse = GetResponse <BrandCreateResponse>(createResult); Assert.Equal("Test brand6", createResponse.Name); var deleteResult = await controller.Delete(createResponse.Id); Assert.IsType <OkResult>(deleteResult); var getResult = await controller.Get(createResponse.Id); var getOkResult = Assert.IsType <OkObjectResult>(getResult); Assert.Null(getOkResult.Value); }
public void Get_ReturnsActionResltType_WhenBrandExists() { var result = brandController.Get(existedBrandId); Assert.IsInstanceOf(typeof(ActionResult <BrandDto>), result); }