public async void GetExternalServiceTypeByName_ReturnsExternalServiceType() { _externalServiceTypeService.Setup(s => s.GetExternalServiceTypeByName(It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync((string serviceName, CancellationToken cancellationToken) => new ExternalServiceType { Id = 1, Name = serviceName }); var controller = new ExternalServiceTypeController(_externalServiceTypeService.Object, _mapper, _logger.Object); var result = await controller.GetExternalServiceType("GitHub"); var okActionResult = Assert.IsType <OkObjectResult>(result); var returnValue = Assert.IsType <ExternalServiceTypeDto>(okActionResult.Value); Assert.Equal("GitHub", returnValue.Name); }
public async void GetExternalServiceTypes_ReturnsExternalServiceTypeList() { _externalServiceTypeService.Setup(s => s.GetExternalServiceTypes(It.IsAny <bool>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new List <ExternalServiceType> { new ExternalServiceType { Id = 1, Name = "GitHub" } }); var controller = new ExternalServiceTypeController(_externalServiceTypeService.Object, _mapper, _logger.Object); var result = await controller.GetExternalServiceTypes(true); var okActionResult = Assert.IsType <OkObjectResult>(result); var returnValue = Assert.IsType <List <ExternalServiceTypeDto> >(okActionResult.Value); Assert.NotEmpty(returnValue); }