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

            var request = new GetAllCommandsRequest
            {
                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 <GetAllCommandsResponse> Get(GetAllCommandsRequest 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);
            }

            return(new GetAllCommandsResponse
            {
                Commands = step.Commands.ConvertTo <List <DomainModels.Command> >()
            });
        }
コード例 #3
0
        public void Get_All_Commands_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 GetAllCommandsRequest
            {
                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
        public async Task It_Should_Get_All_Commands()
        {
            // 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 GetAllCommandsRequest
            {
                BatchId  = TestBatchId,
                StepName = TestStepName
            };

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

            // Assert
            response.Commands.Should().BeEquivalentTo(TestData.DomainModels.Steps.Build.Commands);
        }