public async Task <GetAllCommandVariableResponse> Get(GetAllCommandVariableRequest 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 command = await commandRepository.Get(step.Id, request.CommandName); if (command == null) { throw Err.CommandNotFound(request.CommandName); } var response = new GetAllCommandVariableResponse { Variables = command.Variables.ConvertTo <List <DomainModels.Variable> >() }; return(response); }
public void Get_All_CommandVariables_Should_Throw_With_Invalid_Batch_Id() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(false); var request = new GetAllCommandVariableRequest { BatchId = TestBatchId }; // Act / Assert var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Get(request)); exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString()); exception.Message.Should().Be("Batch TestBatch not found"); }
public void Get_All_CommandVariables_Should_Throw_With_Invalid_Step_Name() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()) .ReturnsNull(); var request = new GetAllCommandVariableRequest { StepName = TestStepName }; // Act / Assert var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Get(request)); exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString()); exception.Message.Should().Be("Step TestStep not found"); }
public async Task It_Should_Get_All_CommandVariable() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()) .Returns(new Step()); var command = TestData.Entities.Commands.Test; commandRepository.Get(Arg.Any <ulong>(), Arg.Any <string>()).Returns(command); var request = new GetAllCommandVariableRequest(); // Act var response = await Sut.Get(request); // Assert response.Variables.Should().BeEquivalentTo(TestData.DomainModels.Commands.Test.Variables); }