예제 #1
0
        private static Product CreateDummyProductToDatabase()
        {
            var dummyProduct = DummyProduct.Product();

            ProductTestContext.DbContext.Product.Add(dummyProduct);
            ProductTestContext.DbContext.SaveChanges();
            return(dummyProduct);
        }
예제 #2
0
        public void UpdateProduct_TryToUpdateProductNotExistInDatabase_ReturnNull()
        {
            //Arrange
            var dummyProduct = DummyProduct.Product();
            //Act
            var updateNullProduct = ProductRepository.UpdateProduct(dummyProduct).Result;

            //Assert
            Assert.IsNull(updateNullProduct);
        }
예제 #3
0
        public void CreateNewProduct_CreatingNewProduct_ReturnCreatedNewProduct()
        {
            //Arrange
            var dummyProduct = DummyProduct.Product();

            //Act
            var newProduct = ProductRepository.CreateProductAsync(dummyProduct).Result;

            //Assert
            Assert.AreEqual(dummyProduct, newProduct);
            DeleteDummyProductFromDatabase(dummyProduct);
        }
예제 #4
0
        public void CreateProdut_CreatingExistingProductInDatabase_ReturnNull()
        {
            //Arrange
            var dummyProduct1 = DummyProduct.Product();
            var dummyProduct2 = dummyProduct1;

            //Act
            var reCreateProduct1 = ProductRepository.CreateProductAsync(dummyProduct1).Result;
            var reCreateProduct2 = ProductRepository.CreateProductAsync(dummyProduct2).Result;

            //Assert
            Assert.AreEqual(reCreateProduct2, null);
        }