public async Task Get_plant_details_success() { //Arrange var plantDetailsContext = new PlantListingContext(_dbOptions); var plantDetailsId = 3; var expectedName = "Japanese Cucumber"; var expectedDescription = "Green color fruit"; var expectedCategory = "Fruit"; var expectedPrice = 1.00m; var expectedWeight = 500.0m; var expectedUnit = "g"; var expectedStock = 50; var expectedUserId = "mgkoh"; //Act var plantDetailsController = new PlantListingController(plantDetailsContext, _mockPlantImageService.Object); var actionResult = await plantDetailsController.GetPlantDetails(plantDetailsId); //Assert Assert.IsType <ActionResult <PlantDetailsViewModel> >(actionResult); Assert.Equal(plantDetailsId, actionResult.Value.PlantDetailsId); Assert.Equal(expectedName, actionResult.Value.Name); Assert.Equal(expectedDescription, actionResult.Value.Description); Assert.Equal(expectedCategory, actionResult.Value.Category); Assert.Equal(expectedPrice, actionResult.Value.Price); Assert.Equal(expectedWeight, actionResult.Value.Weight); Assert.Equal(expectedUnit, actionResult.Value.Unit); Assert.Equal(expectedStock, actionResult.Value.Stock); Assert.Equal(expectedUserId, actionResult.Value.UserId); }
public async Task Get_plant_details_bad_request_response(long plantDetailsId) { //Arrange var plantDetailsContext = new PlantListingContext(_dbOptions); //Act var plantDetailsController = new PlantListingController(plantDetailsContext, _mockPlantImageService.Object); var actionResult = await plantDetailsController.GetPlantDetails(plantDetailsId); //Assert Assert.IsType <ActionResult <PlantDetailsViewModel> >(actionResult); Assert.IsType <BadRequestObjectResult>(actionResult.Result); }