public async Task <IActionResult> GetStackPerStackId(StackIds stackId) { try { return(Ok(await _stackService.GetStackByStackId(stackId))); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest(ex.Message)); } }
public async Task ShouldReturnSuccess_WhenService_GetStackById() { // Arrange var stackId = StackIds.BackEndFrameworks; Stack stack = StackFake.GetStackById(stackId); var stackResponse = new StackResponse { StackId = stack.StackId, StackName = stack.StackName }; _stackRepository.Setup(m => m.GetStackByStackId(It.IsAny <StackIds>())).Returns(Task.FromResult(stack)); _mapper.Setup(m => m.Map <StackResponse>(stack)).Returns(stackResponse); // Act StackResponse result = await _stackService.GetStackByStackId(stackId); // Assert Assert.NotNull(result); Assert.Equal(stack.StackId, result.StackId); Assert.Equal(stack.StackName, result.StackName); }