예제 #1
0
        public void GetCommandItemReturnsNullResultWhenInvalidID()
        {
            //Arrange
            //DB should be empty, any ID will be invalid
            //Act
            var result = _controller.GetCommandById(0);

            //Assert
            Assert.Null(result.Value);
        }
예제 #2
0
        public void GetItemByID_Return404NotFound_WhenNoItemExist()
        {
            mockRepo.Setup(o => o.GetCommandById(0)).Returns(() => null);
            var controller = new CommandsController(mockRepo.Object, mapper);
            var res        = controller.GetCommandById(1);

            Assert.IsType <NotFoundResult>(res.Result);
        }
예제 #3
0
        public void GetCommandById_ReturnsNoFound_WhenCommandDoesNotExists()
        {
            _apiRepoMock.Setup(repo => repo.GetCommandById(0)).Returns(() => null);
            var controller = new CommandsController(_apiRepoMock.Object, _mapper);

            var actual = controller.GetCommandById(3);

            Assert.IsType <NotFoundResult>(actual.Result);
        }
        public void GetCommandByID_Returns404NotFound_WhenNonExistentIDProvided()
        {
            mockRepo.Setup(repo => repo.GetCommandById(0)).Returns(() => null);
            var controller = new CommandsController(mockRepo.Object, mapper);

            var result = controller.GetCommandById(1);

            Assert.IsType <NotFoundResult>(result.Result);
        }
예제 #5
0
        public void GetCommandById_ReturnOk200_WhenIdIsValid()
        {
            mockRepo.Setup(repo => repo.GetCommandById(1)).Returns(GetCommands(1)[0]);
            var controller = new CommandsController(mockRepo.Object, mapper);

            var result = controller.GetCommandById(1);

            Assert.IsType <OkObjectResult>(result.Result);
        }
예제 #6
0
        public void GetCommandById_ReturnCorrectObjectType_WhenIdIsValid()
        {
            mockRepo.Setup(repo => repo.GetCommandById(1)).Returns(GetCommands(1)[0]);
            var controller = new CommandsController(mockRepo.Object, mapper);

            var result = controller.GetCommandById(1);

            Assert.IsType <ActionResult <CommandReadDto> >(result);
        }
예제 #7
0
        public void GetCommandById_Return404_WhenDbIsEmpty()
        {
            mockRepo.Setup(repo => repo.GetCommandById(0)).Returns(() => null);
            var controller = new CommandsController(mockRepo.Object, mapper);

            var result = controller.GetCommandById(0);

            Assert.IsType <NotFoundResult>(result.Result);
        }
예제 #8
0
        public void GetCommandByID_Returns404NotFound_WhenNonExistentIDProvided()
        {
            // setup the GetCommandsById method on the mock repository to return null when an Id of “0” is passed in
            mockRepo.Setup(repo => repo.GetCommandById(0)).Returns(() => null);
            var controller = new CommandsController(mockRepo.Object, mapper);
            //Act
            var result = controller.GetCommandById(1);

            //Assert
            Assert.IsType <NotFoundResult>(result.Result);
        }
예제 #9
0
        public void GetCommandById_ReturnsOk_WhenCommandExists()
        {
            _apiRepoMock.Setup(repo => repo.GetCommandById(1)).Returns(new Command()
            {
                Id = 1, CommandLine = "mockCommand", HowTo = "mockHowTo", Platform = "mockPlatform"
            });
            var controller = new CommandsController(_apiRepoMock.Object, _mapper);

            var actual = controller.GetCommandById(1);

            Assert.IsType <OkObjectResult>(actual.Result);
        }
예제 #10
0
        public void GetCommandById_ReturnsCommandReadDto_WhenCommandExists()
        {
            _apiRepoMock.Setup(repo => repo.GetCommandById(2)).Returns(new Command()
            {
                Id = 2, CommandLine = "mockCommand", HowTo = "mockHowTo", Platform = "mockPlatform"
            });
            var controller = new CommandsController(_apiRepoMock.Object, _mapper);

            var actual = controller.GetCommandById(2);

            Assert.IsType <ActionResult <CommandReadDto> >(actual);
        }
        public void GetCommandById_Returns404NotFound_WhenNonExistantIdIsProvided()
        {
            // Arrange
            mockRepository.Setup(repo => repo.GetCommandById(0)).Returns(() => null);
            var controller = new CommandsController(mockRepository.Object, mapper);

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

            // Assert
            Assert.IsType <NotFoundResult>(result.Result);
        }
예제 #12
0
        public void GetCommandByID_Returns200Ok_WhenValidIDProvided()
        {
            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.GetCommandById(1);

            Assert.IsType <ActionResult <CommandReadDto> >(result);
        }
예제 #13
0
        public void GetCommandByID_Returns404NotFound_WhenNonExistentIDProvided()
        {
            //Arrange
            mockRepo.Setup(repo => repo.GetCommandById(0)).Returns(() => null);
            CommandsController controller = new CommandsController(mockRepo.Object, mapper);

            //Act
            ActionResult <CommandReadDto> result = controller.GetCommandById(1);

            //Assert
            Assert.IsType <NotFoundResult>(result.Result);
        }
        public void GetCommandByID_Returns200OK_WhenValidIDProvided()
        {
            //Arrange
            mockRepo.Setup(repo => repo.GetCommandById(1)).Returns(GetCommand(1));

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

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

            //Assert
            Assert.IsType <OkObjectResult>(result.Result);
        }
        public void GetCommandByID_ReturnsCorrectType_WhenValidIDProvided()
        {
            //Arrange
            mockRepo.Setup(repo => repo.GetCommandById(1)).Returns(GetCommand(1));

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

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

            //Assert
            Assert.IsType <ActionResult <CommandReadDto> >(result);
        }
        public void GetCommandById_ReturnsObjectOfExpectedType_WhenValidIdProvided()
        {
            //Arrange
            mockRepo.Setup(repo => repo.GetCommandById(1)).Returns(() =>
                                                                   GetCommand(1, "mock", "Mock", "Mock"));

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

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

            //Assert
            Assert.IsType <ActionResult <CommandReadDto> >(result);
        }
예제 #17
0
        public void GetCommandByID_CorrectType_WhenCommandFound()
        {
            mockRepo.Setup(o => o.GetCommandById(0)).Returns(new Command {
                Id          = 0,
                HowTo       = "mock",
                Platform    = "mock",
                CommandLine = "mock"
            });
            var controller = new CommandsController(mockRepo.Object, mapper);

            var res = controller.GetCommandById(0);

            Assert.IsType <ActionResult <CommandReadDto> >(res);
        }
예제 #18
0
        public void GetCommandByID_Return200ok_WhenCommandFound()
        {
            mockRepo.Setup(o => o.GetCommandById(0)).Returns(new Command {
                Id          = 0,
                HowTo       = "mock",
                Platform    = "mock",
                CommandLine = "mock"
            });
            var controller = new CommandsController(mockRepo.Object, mapper);

            var res = controller.GetCommandById(0);

            Assert.IsType <OkObjectResult>(res.Result);
        }
        public void GetCommandByID_Returns200Ok_WhenValidIDIsProvided()
        {
            //Arrange
            mockRepo.Setup(repo => repo.GetCommandById(1)).Returns(new Command {
                Id = 1, HowTo = "mock", Platform = "Mock", CommandLine = "Mock"
            });

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

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

            //Assert
            Assert.IsType <OkObjectResult>(result.Result);
        }
        public void GetCommandById_Returns200OK_WhenValidIDProvided()
        {
            // Arrange
            _mockApiRepo.Setup(repo => repo.GetCommandById(0)).Returns(
                new Command {
                Id = 0, HowTo = "Mock", Platform = "MockPL", CommandLine = "Mock"
            });

            var controller = new CommandsController(_mockApiRepo.Object, _mapper);

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

            // Assert

            Assert.IsType <OkObjectResult>(result.Result);
        }
        public void GetCommandById_ReturnsCorrectType_WhenValidIdIsProvided()
        {
            // 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.GetCommandById(1);

            // Assert
            Assert.IsType <ActionResult <CommandReadDTO> >(result);
        }
예제 #22
0
        public void GetCommandById_ReturnsCorrectType_WhenValidIdProvided()
        {
            //Given
            mockRepo.Setup(repo => repo.GetCommandById(1)).Returns(() => new Command
            {
                Id          = 1,
                HowTo       = "mock",
                Platform    = "Mock",
                CommandLine = "Mock"
            });
            var controller = new CommandsController(mockRepo.Object, mapper);

            //When
            var result = controller.GetCommandById(1);

            //Then
            Assert.IsType <ActionResult <CommandReadDto> >(result);
        }
예제 #23
0
        public void ShouldReturnMyName()
        {
            var actual = controller.GetCommandById(1);

            Assert.Equal("Something else", actual.Value);
        }