コード例 #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);
        }