Exemplo n.º 1
0
        public async Task It_Should_Get_StepOption()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(true);

            stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()).Returns(new Step
            {
                Id = 123
            });

            var stepOption = StepOptions.BuildWhenNoErrors;

            stepRepository.GetStepOption(Arg.Any <ulong>(), Arg.Any <string>())
            .Returns(stepOption);

            var request = new GetStepOptionRequest();

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

            // Assert
            response.Should().BeEquivalentTo(TestData.DomainModels.StepOptions.BuildWhenNoErrors,
                                             o => o.ExcludingMissingMembers());
            response.OptionName.Should().Be(TestData.DomainModels.StepOptions.BuildWhenNoErrors.Name);
        }
Exemplo n.º 2
0
        public void Get_StepOption_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(false);

            var request = new GetStepOptionRequest
            {
                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");
        }
Exemplo n.º 3
0
        public void Get_StepOption_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 GetStepOptionRequest
            {
                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");
        }
Exemplo n.º 4
0
        public async Task <GetStepOptionResponse> Get(GetStepOptionRequest 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 stepOption = await stepRepository.GetStepOption(step.Id, request.OptionName);

            if (stepOption == null)
            {
                throw Err.StepOptionNotFound(request.OptionName);
            }

            return(stepOption.ConvertTo <GetStepOptionResponse>());
        }