public async Task <IActionResult> GetISAById(string isaId) { try { if (!ObjectIdValidator.Validate(isaId)) { return(BadRequest("Please enter valid ISA Id.")); } var facilityKey = Guid.Parse(executionContextAccessor.Current.Facility.FacilityKey); _logger.LogInformation(LoggingConstants.GetISAById, facilityKey); ISA isa = await _isaManager.GetISAById(isaId, facilityKey); if (isa == null) { _logger.LogError(LoggingConstants.Empty_List); return(NotFound($"ISA with ISA ID {isaId} not found")); } return(Ok(isa)); } catch (Exception ex) { _logger.LogError(ex.Message); return(StatusCode(500)); } }
public async Task GetISAById() { var id = "1234"; var guid = Guid.NewGuid(); var createdDate = DateTime.Now; var modifiedDate = DateTime.Now; var dummyItemStorageSpace = GetMockItemStorageSpace(id, guid, createdDate, modifiedDate); var dummyResponse = GetMockISA(dummyItemStorageSpace); //Arrange mockRepo.Reset(); mockRepo.Setup(b => b.GetISAById(It.IsAny <String>(), It.IsAny <Guid>())) .ReturnsAsync(dummyItemStorageSpace); //Act var result = await subject_test.GetISAById(id, guid); //Assert mockRepo.Verify(); Assert.NotNull(result); }