public void Delete_deletes_a_ProductOption_via_context()
        {
            //Arrange
            var repository = new ProductOptionRepository(_mapper, _mockContext,_logging);

            //Act
            repository.Delete(new Guid("a21d5777-a655-4020-b431-624bb331e9a2"));
            var productOptions = repository.GetAll();

            //Assert
            Assert.IsNotNull(productOptions);
            Assert.AreEqual(productOptions.Count(),2);
        }
        public IHttpActionResult DeleteProductOption(Guid id)
        {
            ProductOption productOption = db.GetOne(id);

            if (productOption == null)
            {
                return(NotFound());
            }

            db.Delete(productOption);

            return(Ok(productOption));
        }
Example #3
0
        public void ProductOptionRepositoryDeleteByEntityTest()
        {
            //Arrange
            ProductOption productOption = new ProductOption
            {
                Id          = new Guid("a21d5777-a655-4020-b431-624bb331e9a2"),
                ProductId   = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"),
                Name        = "HUAWEI",
                Description = "HUAWEI HONOR Updated"
            };

            //Action
            using (ProductOptionRepository productOptionRepository = new ProductOptionRepository())
            {
                //Assert
                Assert.AreEqual(1, productOptionRepository.Delete(productOption));
            }
        }
        public void InsertAndDeleteTest()
        {
            ProductOptionRepository repo = new ProductOptionRepository();

            Guid id = new Guid();

            ProductOption test = new ProductOption(id, Guid.Parse("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), "TestProductOption", "This is a unit test created product option");

            repo.Insert(test);

            ProductOption postInsert = repo.GetByID(id);

            Assert.AreEqual(test.Id, postInsert.Id);
            Assert.AreEqual(test.ProductId, postInsert.ProductId);
            Assert.AreEqual(test.Name, postInsert.Name);
            Assert.AreEqual(test.Description, postInsert.Description);

            repo.Delete(postInsert);

            ProductOption postDelete = repo.GetByID(id);

            Assert.IsNull(postDelete);
        }