コード例 #1
0
        public void Get_All_StepOptions_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(false);

            var request = new GetAllStepOptionRequest
            {
                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");
        }
コード例 #2
0
        public async Task It_Should_Get_All_StepOption()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(true);

            var step = TestData.Entities.Steps.Build;

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

            var request = new GetAllStepOptionRequest();

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

            // Assert
            response.Options.Should().BeEquivalentTo(TestData.DomainModels.Steps.Build.Options);
        }
コード例 #3
0
        public void Get_All_StepOptions_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 GetAllStepOptionRequest
            {
                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");
        }
コード例 #4
0
ファイル: StepOptionService.cs プロジェクト: BakanaCI/Bakana
        public async Task <GetAllStepOptionResponse> Get(GetAllStepOptionRequest 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 response = new GetAllStepOptionResponse
            {
                Options = step.Options.ConvertTo <List <DomainModels.Option> >()
            };

            return(response);
        }