public async void Create_InvalidObjectPassed_ReturnsBadRequest()
        {
            // Arrange
            var           controller = new ProductController(service);
            CreateProduct addManager = new CreateProduct();
            var           productAdd = addManager.addInvalid();

            controller.ModelState.AddModelError("IdCategory", "Required");

            // Act
            var badResponse = await controller.Create(productAdd);

            // Assert
            var result = badResponse.Should().BeOfType <BadRequestObjectResult>().Subject;
            //Assert.IsType<BadRequestObjectResult>(badResponse);
        }
        public async void Create_WhenAdded_OkResult()
        {
            //Arrange
            var           controller = new ProductController(service);
            CreateProduct addManager = new CreateProduct();
            var           productAdd = addManager.add();
            //find it
            int idnew = 3;

            //Act
            var productAddRq = await controller.Create(productAdd);

            var productRq = await controller.GetProduct(idnew);

            var resultProductRq = productRq.Should().BeOfType <OkObjectResult>().Subject;

            //Assert
            var result = productAddRq.Should().BeOfType <OkResult>().Subject;

            Assert.Equal(idnew, resultProductRq.Value.Should().BeAssignableTo <ProductViewModel>().Subject.IdProduct);
        }
        public async void Create_ValidObjectPassed_ReturnedResponseHasCreatedItem()
        {
            // Arrange
            var           controller = new ProductController(service);
            CreateProduct addManager = new CreateProduct();
            var           productAdd = addManager.add();

            //context
            var context = new DbContextDrugStore(dbContextOptions);


            // Act
            var resultOk = await controller.Create(productAdd);

            var records     = db.CountRecords(context);
            var Allproducts = await controller.List();

            // Assert
            var AllresultsList = Allproducts.Should().BeAssignableTo <IEnumerable <ProductViewModel> >().Subject;

            AllresultsList.Should().HaveCount(records);
        }