Esempio n. 1
0
        public void DeleteCommand_Returns_404NotFound_WhenNonExistentResourceIDSubmitted()
        {
            //Arrange
            // added 9/1/20 to trigger
            mockRepo.Setup(repo =>
                           repo.GetCommandById(0)).Returns(() => null);

            var controller = new CommandsController(mockRepo.Object, mapper);

            //Act
            var result = controller.DeleteCommand(0);

            //Assert
            Assert.IsType <NotFoundResult>(result);
        }
        public void DeleteCommand_Returns204NoContent_WhenValidResourceIDSubmitted()
        {
            mockRepo.Setup(repo => repo.GetCommandById(1)).Returns(new Command
            {
                Id          = 1,
                HowTo       = "mock",
                Platform    = "Mock",
                CommandLine = "Mock"
            });
            var controller = new CommandsController(mockRepo.Object, mapper);

            var result = controller.DeleteCommand(1);

            Assert.IsType <NoContentResult>(result);
        }
Esempio n. 3
0
        public void DeleteCommand_Returns204NoContent_WhenResourceNotExistsIdSubmitted()
        {
            _apiRepoMock.Setup(repo => repo.GetCommandById(1)).Returns(new Command()
            {
                Id          = 1,
                HowTo       = "mock",
                Platform    = "Mock",
                CommandLine = "Mock"
            });
            var controller = new CommandsController(_apiRepoMock.Object, _mapper);

            var actual = controller.DeleteCommand(2);

            Assert.IsType <NotFoundResult>(actual);
        }
        public void DeleteCommand_Returns204NoContent_WhenValidIdProvided()
        {
            // Arrange
            mockRepository.Setup(repo => repo.GetCommandById(1)).Returns(new Command
            {
                Id          = 1,
                HowTo       = "Mock",
                Platform    = "Mock",
                CommandLine = "Mock"
            });
            var controller = new CommandsController(mockRepository.Object, mapper);

            // Act
            var result = controller.DeleteCommand(1);

            // Assert
            Assert.IsType <NoContentResult>(result);
        }