public async Task <GetAllStepArtifactOptionResponse> Get(GetAllStepArtifactOptionRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var step = await stepRepository.Get(request.BatchId, request.StepName); if (step == null) { throw Err.StepNotFound(request.StepName); } var existingStepArtifact = await stepRepository.GetStepArtifact(step.Id, request.ArtifactName); if (existingStepArtifact == null) { throw Err.StepArtifactNotFound(request.ArtifactName); } var response = new GetAllStepArtifactOptionResponse { Options = existingStepArtifact.Options.ConvertTo <List <DomainModels.Option> >() }; return(response); }
public void Get_All_StepArtifact_Options_Should_Throw_With_Invalid_Batch_Id() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(false); var request = new GetAllStepArtifactOptionRequest { BatchId = TestBatchId }; // Act / Assert var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Get(request)); exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString()); exception.Message.Should().Be("Batch TestBatch not found"); }
public void Get_All_StepArtifact_Options_Should_Throw_With_Invalid_Step_Name() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()) .ReturnsNull(); var request = new GetAllStepArtifactOptionRequest { StepName = TestStepName }; // Act / Assert var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Get(request)); exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString()); exception.Message.Should().Be("Step TestStep not found"); }