public async Task StorageLocation_AddAsync() { var storageLocation = _fixture.Create <StorageLocation>(); var storageLocationCreateModel = _fixture.Create <StorageLocationCreateViewModel>(); _mockIMapper.Setup(m => m.Map <StorageLocationCreateViewModel, StorageLocation>(storageLocationCreateModel)).Returns(storageLocation); _mockStorageLocationRepository.Setup(m => m.AddAsync(storageLocation)).ReturnsAsync(1); var actionSuccess = await _storageLocationService.AddAsync(storageLocationCreateModel); actionSuccess.Should().Be(true); Mock.VerifyAll(); }
public async Task <IActionResult> NewStorageLocation(StorageLocationCreateViewModel storageLocation) { try { var success = await _storageLocationService.AddAsync(storageLocation); if (success) { return(Created("", storageLocation)); } return(BadRequest($"Erro ao criar local")); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }