Ejemplo n.º 1
0
        public async Task GetById_ShouldReturnNotFoundWhenTeamIsNull()
        {
            mockTeamService.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync((Team)null);
            var result = await TeamController.GetById(1);

            Assert.IsType <NotFoundResult>(result);
        }
Ejemplo n.º 2
0
        public void FindTeamCorrect()
        {
            var teamDTO = new TeamDTO
            {
                Id   = 1,
                Naam = "Quiz 1"
            };
            var response = new Response <TeamDTO> {
                DTO = teamDTO
            };

            //Arrange
            var mockService = new Mock <ITeamService>();

            mockService.Setup(x => x.FindTeam(1)).Returns(response);
            var controller = new TeamController(mockService.Object);

            //Act
            var foundTeam = controller.GetById(1) as ObjectResult;
            var entity    = foundTeam.Value as TeamViewModelResponse;

            //Assert
            Assert.That(entity.Id, Is.EqualTo(teamDTO.Id));
            Assert.That(entity.Naam, Is.EqualTo(teamDTO.Naam));
        }
Ejemplo n.º 3
0
        public async Task GetById_ReturnsJsonWithTeam_WhenIdIsValid()
        {
            var teamId = Guid.NewGuid();
            var userId = Guid.NewGuid();

            SetupRequestHeader(_sut, userId);

            _teamServiceMock
            .Setup(teamService => teamService.GetAsync(userId, teamId))
            .ReturnsAsync(new TeamDto());

            var result = await _sut.GetById(teamId);

            var jsonResult = result as JsonResult;

            Assert.NotNull(jsonResult?.Value as TeamApiModel);
        }
Ejemplo n.º 4
0
        public void FindTeamNull()
        {
            var teamDTO = new TeamDTO
            {
                Id   = 1,
                Naam = "Team A"
            };
            var response = new Response <TeamDTO> {
                DTO = teamDTO
            };

            //Arrange
            var mockService = new Mock <ITeamService>();

            mockService.Setup(x => x.FindTeam(1)).Returns(response);
            var controller = new TeamController(mockService.Object);

            //Act
            var foundTeam = controller.GetById(5) as ObjectResult;

            //Assert
            Assert.IsInstanceOf(typeof(BadRequestObjectResult), foundTeam);
        }