Beispiel #1
0
        public async Task <DeleteStepArtifactOptionResponse> Delete(DeleteStepArtifactOptionRequest 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 existingStepArtifactOption = await stepRepository.GetStepArtifactOption(existingStepArtifact.Id, request.OptionName);

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

            await stepRepository.DeleteStepArtifactOption(existingStepArtifactOption.Id);

            return(new DeleteStepArtifactOptionResponse());
        }
Beispiel #2
0
        public async Task It_Should_Delete_Step_Artifact_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 existingStepArtifactOption = new StepArtifactOption
            {
                Id = 123
            };

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

            stepRepository.DeleteStepArtifactOption(Arg.Any <ulong>()).Returns(true);

            var request = new DeleteStepArtifactOptionRequest();

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

            // Assert
            response.Should().NotBeNull();
            await stepRepository.Received().DeleteStepArtifactOption(Arg.Is <ulong>(a =>
                                                                                    a == existingStepArtifactOption.Id));
        }
Beispiel #3
0
        public void Delete_Step_Artifact_Option_Should_Throw_With_Invalid_Step_Artifact_Option_Name()
        {
            // 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());

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

            var request = new DeleteStepArtifactOptionRequest
            {
                OptionName = TestStepArtifactOptionName
            };

            // Act / Assert
            var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Delete(request));

            exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString());
            exception.Message.Should().Be("Step Artifact Option TestStepArtifactOption not found");
        }
Beispiel #4
0
        public void Delete_Step_Artifact_Option_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(false);

            var request = new DeleteStepArtifactOptionRequest
            {
                BatchId = TestBatchId
            };

            // Act / Assert
            var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Delete(request));

            exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString());
            exception.Message.Should().Be("Batch TestBatch not found");
        }