Exemple #1
0
        public async void InsertbyProduct_CallsInsertbyProductOnMockRepo_ReturnsCreatedObjectResult()
        {
            //Arrange
            var expectedProduct = new Product()
            {
            };

            mockRepo.Setup(repo => repo.InsertbyProduct(expectedProduct)).Returns(Task.FromResult <Product>(new Product {
            }));

            //Act
            var result = await controller.InsertbyProduct(expectedProduct);

            var resultObj = result as CreatedResult;

            //Asset
            mockRepo.Verify(repo => repo.InsertbyProduct(expectedProduct), Times.Once);

            Assert.NotNull(resultObj);
            Assert.Equal(201, resultObj.StatusCode);
        }