Пример #1
0
        public void Delete_Negative()
        {
            // Arrange
            var repository = new Mock <IFunFactsRepository>();
            var fact       = new ChuckNorrisFunFact();

            repository.Setup(ffr => ffr.Get(It.Is <long>(i => i == 2))).Returns <IFunFact>(null);
            ChuckNorrisFunFactsController controller = new ChuckNorrisFunFactsController(repository.Object);

            // Act
            var response = controller.Delete(2);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(NotFoundResult));
        }
Пример #2
0
        public void Delete_OK()
        {
            // Arrange
            var repository = new Mock <IFunFactsRepository>();

            repository.Setup(ffr => ffr.Delete(It.Is <long>(i => i == 2))).Returns(true);
            ChuckNorrisFunFactsController controller = new ChuckNorrisFunFactsController(repository.Object);

            // Act
            var response = controller.Delete(2);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkResult));
            repository.VerifyAll();
        }