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

            var request = new GetAllStepArtifactRequest
            {
                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");
        }
Esempio n. 2
0
        public void Get_All_StepArtifacts_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 GetAllStepArtifactRequest
            {
                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");
        }
Esempio n. 3
0
        public async Task <GetAllStepArtifactResponse> Get(GetAllStepArtifactRequest 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 stepArtifacts = await stepRepository.GetAllStepArtifacts(step.Id);

            var response = new GetAllStepArtifactResponse
            {
                Artifacts = stepArtifacts.ConvertTo <List <DomainModels.StepArtifact> >()
            };

            return(response);
        }
Esempio n. 4
0
        public async Task It_Should_Get_All_StepArtifact()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(true);

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

            var stepArtifacts = TestData.Entities.Steps.Build.Artifacts;

            stepRepository.GetAllStepArtifacts(Arg.Any <ulong>())
            .Returns(stepArtifacts);

            var request = new GetAllStepArtifactRequest();

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

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