public async void Task_Return_GetAllProductCategory() { var controller = new ProductCategoryController(context); var data = await controller.Get(); Assert.IsType <OkObjectResult>(data); }
public async void Task_GetProductCategoryById_BadResult() { var controller = new ProductCategoryController(context); int?id = null; var data = await controller.Get(id); Assert.IsType <BadRequestResult>(data); }
public async void Task_GetProductCategoryBy_Id_Return_NoResult() { var controller = new ProductCategoryController(context); var ProductCategoryId = 6; var data = await controller.Get(ProductCategoryId); Assert.IsType <NotFoundResult>(data); }
public async void Task_GetProductCategoryBy_Id_Return_OkResult() { var controller = new ProductCategoryController(context); var ProductCategoryId = 1; var data = await controller.Get(ProductCategoryId); Assert.IsType <OkObjectResult>(data); }
public async void Task_GetPCById_Return_FailResult() { var controller = new ProductCategoryController(context); var Id = 25; var data = await controller.Get(Id); Assert.IsType <NotFoundResult>(data); }
public async void Task_GetPCById_Return_getBadRequestResult() { //Arrange var controller = new ProductCategoryController(context); int?id = null; //Act var data = await controller.Get(id); //Assert Assert.IsType <BadRequestResult>(data); }
public async void Task_GetProductCategoryById_MatchResult() { var controller = new ProductCategoryController(context); int id = 1; var data = await controller.Get(id); Assert.IsType <OkObjectResult>(data); var okResult = data.Should().BeOfType <OkObjectResult>().Subject; var prod = okResult.Value.Should().BeAssignableTo <ProductCategory>().Subject; Assert.Equal("Summer Collection", prod.CategoryName); Assert.Equal("Cotton", prod.CategoryDescription); }
public async void Task_GetPCById_Return_getMatched() { var controller = new ProductCategoryController(context); int id = 1; var data = await controller.Get(id); Assert.IsType <OkObjectResult>(data); var okResult = data.Should().BeOfType <OkObjectResult>().Subject; var pc = okResult.Value.Should().BeAssignableTo <Categories>().Subject; Assert.Equal("Summer", pc.CategoryName); Assert.Equal("printed", pc.CategoryDescription); }
public async void Task_GetUserById_MatchResult() { var controller = new ProductCategoryController(_context); int id = 1; var data = await controller.Get(id); Assert.IsType <OkObjectResult>(data); var OkResult = data.Should().BeOfType <OkObjectResult>().Subject; var user = OkResult.Value.Should().BeAssignableTo <ProductCategory>().Subject; Assert.Equal("Top wear", user.CategoryName); Assert.Equal("Comfortable wear in every season", user.CategoryDescription); }
public async void Task_GetAll_NotFound() { var controller = new ProductCategoryController(_context); var data = await controller.Get(); data = null; if (data != null) { Assert.IsType <OkObjectResult>(data); } else { // Assert.Equal(data, null); } }
public async void Get_Not_Exists() { ProductCategoryControllerMockFacade mock = new ProductCategoryControllerMockFacade(); mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiProductCategoryResponseModel>(null)); ProductCategoryController controller = new ProductCategoryController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Get(default(int)); response.Should().BeOfType <StatusCodeResult>(); (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound); mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>())); }