コード例 #1
0
        public async Task DeletePatternShouldDeletePattern()
        {
            var pattern = new Pattern {
                Id = 1
            };

            _projectBLMock.Setup(x => x.DeletePatternAsync(It.IsAny <Pattern>())).Returns(Task.FromResult <Pattern>(pattern));
            var patternController = new PatternController(_projectBLMock.Object);
            var result            = await patternController.DeletePatternAsync(pattern.Id);

            Assert.IsAssignableFrom <NoContentResult>(result);
            _projectBLMock.Verify(x => x.DeletePatternAsync((It.IsAny <Pattern>())));
        }
コード例 #2
0
        public async Task DeletePatternAsync_ShouldReturnStatusCode500_WhenPatternIsInvalid()
        {
            //arrange
            int     id      = 1;
            Pattern pattern = null;

            _projectBLMock.Setup(i => i.DeletePatternAsync(pattern)).Throws(new Exception());
            PatternController patternController = new PatternController(_projectBLMock.Object);

            //act
            var result = await patternController.DeletePatternAsync(id);

            //assert
            Assert.IsType <StatusCodeResult>(result);
            Assert.Equal(500, ((StatusCodeResult)result).StatusCode);
        }