Ejemplo n.º 1
0
        public void Get_All_BatchArtifact_Options_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(false);

            var request = new GetAllBatchArtifactOptionRequest
            {
                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");
        }
Ejemplo n.º 2
0
        public async Task <GetAllBatchArtifactOptionResponse> Get(GetAllBatchArtifactOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName);

            if (batchArtifact == null)
            {
                throw Err.BatchArtifactNotFound(request.ArtifactName);
            }

            var response = new GetAllBatchArtifactOptionResponse
            {
                Options = batchArtifact.Options.ConvertTo <List <DomainModels.Option> >()
            };

            return(response);
        }