Ejemplo n.º 1
0
        public async Task AddAdmin_Valid_Test()
        {
            // Arrange
            _mapper
            .Setup(m => m.Map <ClubAdministrationViewModel, ClubAdministrationDTO>(It.IsAny <ClubAdministrationViewModel>()))
            .Returns(new ClubAdministrationDTO()
            {
                AdminType = new BLL.DTO.Admin.AdminTypeDTO()
            });
            _ClubParticipantsService
            .Setup(c => c.AddAdministratorAsync(It.IsAny <ClubAdministrationDTO>()));
            _logger
            .Setup(l => l.LogInformation(It.IsAny <string>()));
            ClubController Clubcon = CreateClubController;

            // Act
            var result = await Clubcon.AddAdmin(new ClubAdministrationViewModel());

            // Assert
            Assert.NotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
        }
Ejemplo n.º 2
0
        public async Task AddAdmin_ReturnsOkObjectResult()
        {
            //Arrange
            var clubId = GetClubId();

            _clubService
            .Setup(x => x.GetClubInfoByIdAsync(clubId))
            .ReturnsAsync(new ClubDTO());
            _mapper
            .Setup(m => m.Map <ClubAdministrationViewModel, ClubAdministrationDTO>(
                       It.IsAny <ClubAdministrationViewModel>()))
            .Returns(new ClubAdministrationDTO()
            {
                ClubId = clubId
            });
            _mapper
            .Setup(m => m.Map <ClubAdministrationDTO, ClubAdministrationViewModel>(
                       It.IsAny <ClubAdministrationDTO>()))
            .Returns(new ClubAdministrationViewModel());
            _clubAdministrationService
            .Setup(x => x.AddClubAdminAsync(It.IsAny <ClubAdministrationDTO>()))
            .ReturnsAsync(new ClubAdministrationDTO());

            //Act
            var result = await _clubController.AddAdmin(clubId, It.IsAny <ClubAdministrationViewModel>());

            var resultValue = (result as OkObjectResult).Value;

            //Assert
            _clubService.Verify();
            _mapper.Verify();
            Assert.IsNotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
            Assert.IsNotNull(resultValue);
            Assert.IsInstanceOf <ClubAdministrationViewModel>(resultValue);
        }