public void Update_BatchOption_Should_Throw_With_Invalid_Batch_Id() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(false); var request = new UpdateBatchOptionRequest { BatchId = TestBatchId }; // Act / Assert var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Put(request)); exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString()); exception.Message.Should().Be("Batch TestBatch not found"); }
public async Task <UpdateBatchOptionResponse> Put(UpdateBatchOptionRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var existingBatchOption = await batchRepository.GetBatchOption(request.BatchId, request.OptionName); if (existingBatchOption == null) { throw Err.BatchOptionNotFound(request.OptionName); } var batchOption = request.ConvertTo <BatchOption>(); batchOption.Id = existingBatchOption.Id; await batchRepository.CreateOrUpdateBatchOption(batchOption); return(new UpdateBatchOptionResponse()); }