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

            var existingBatchArtifact = new BatchArtifact
            {
                Id = 123
            };

            batchRepository.GetBatchArtifact(Arg.Any <string>(), Arg.Any <string>())
            .Returns(existingBatchArtifact);

            batchRepository.DeleteBatchArtifact(Arg.Any <ulong>()).Returns(true);

            var request = new DeleteBatchArtifactRequest();

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

            // Assert
            response.Should().NotBeNull();
            await batchRepository.Received().DeleteBatchArtifact(Arg.Is <ulong>(a =>
                                                                                a == existingBatchArtifact.Id));
        }
Exemplo n.º 2
0
        public void Delete_Batch_Artifact_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(false);

            var request = new DeleteBatchArtifactRequest
            {
                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");
        }
Exemplo n.º 3
0
        public async Task <DeleteBatchArtifactResponse> Delete(DeleteBatchArtifactRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var existingBatchArtifact =
                await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName);

            if (existingBatchArtifact == null)
            {
                throw Err.BatchArtifactNotFound(request.ArtifactName);
            }

            await batchRepository.DeleteBatchArtifact(existingBatchArtifact.Id);

            return(new DeleteBatchArtifactResponse());
        }