public void Update_BatchVariable_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(false);

            var request = new UpdateBatchVariableRequest
            {
                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");
        }
Exemple #2
0
        public async Task <UpdateBatchVariableResponse> Put(UpdateBatchVariableRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var existingBatchVariable =
                await batchRepository.GetBatchVariable(request.BatchId, request.VariableName);

            if (existingBatchVariable == null)
            {
                throw Err.BatchVariableNotFound(request.VariableName);
            }

            var batchVariable = request.ConvertTo <BatchVariable>();

            batchVariable.Id = existingBatchVariable.Id;

            await batchRepository.CreateOrUpdateBatchVariable(batchVariable);

            return(new UpdateBatchVariableResponse());
        }