Ejemplo n.º 1
0
        public async Task <GetStepArtifactOptionResponse> Get(GetStepArtifactOptionRequest 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 stepArtifactOption = await stepRepository.GetStepArtifactOption(existingStepArtifact.Id, request.OptionName);

            if (stepArtifactOption == null)
            {
                throw Err.StepArtifactOptionNotFound(request.OptionName);
            }

            return(stepArtifactOption.ConvertTo <GetStepArtifactOptionResponse>());
        }
Ejemplo n.º 2
0
        public async Task It_Should_Get_StepArtifact_Option()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(true);

            stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()).Returns(new Step());

            stepRepository.GetStepArtifact(Arg.Any <ulong>(), Arg.Any <string>())
            .Returns(new StepArtifact());

            var stepArtifactOption = TestData.Entities.StepArtifactOptions.Extract;

            stepRepository.GetStepArtifactOption(Arg.Any <ulong>(), Arg.Any <string>())
            .Returns(stepArtifactOption);

            // Act
            var response = await Sut.Get(new GetStepArtifactOptionRequest());

            // Assert
            response.Should().BeEquivalentTo(StepArtifactOptions.Extract,
                                             o => o.ExcludingMissingMembers());
            response.OptionName.Should().Be(StepArtifactOptions.Extract.Name);
        }