public async Task It_Should_Delete_Batch_Artifact_Option() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); var existingBatchArtifact = new BatchArtifact { Id = 123 }; batchRepository.GetBatchArtifact(Arg.Any <string>(), Arg.Any <string>()) .Returns(existingBatchArtifact); var existingBatchArtifactOption = new BatchArtifactOption { Id = 456 }; batchRepository.GetBatchArtifactOption(Arg.Any <ulong>(), Arg.Any <string>()) .Returns(existingBatchArtifactOption); batchRepository.DeleteBatchArtifactOption(Arg.Any <ulong>()).Returns(true); var request = new DeleteBatchArtifactOptionRequest(); // Act var response = await Sut.Delete(request); // Assert response.Should().NotBeNull(); await batchRepository.Received().DeleteBatchArtifactOption(Arg.Is <ulong>(a => a == existingBatchArtifactOption.Id)); }
public async Task <DeleteBatchArtifactOptionResponse> Delete(DeleteBatchArtifactOptionRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName); if (batchArtifact == null) { throw Err.BatchArtifactNotFound(request.ArtifactName); } var existingBatchArtifactOption = await batchRepository.GetBatchArtifactOption(batchArtifact.Id, request.OptionName); if (existingBatchArtifactOption == null) { throw Err.BatchArtifactOptionNotFound(request.OptionName); } await batchRepository.DeleteBatchArtifactOption(existingBatchArtifactOption.Id); return(new DeleteBatchArtifactOptionResponse()); }
public void Delete_Batch_Artifact_Option_Should_Throw_With_Invalid_Batch_Id() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(false); var request = new DeleteBatchArtifactOptionRequest { 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"); }