public void Get_CommandVariable_Should_Throw_With_Invalid_Variable_Id() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()) .Returns(new Step()); commandRepository.Get(Arg.Any <ulong>(), Arg.Any <string>()) .Returns(new Command()); commandRepository.GetCommandVariable(Arg.Any <ulong>(), Arg.Any <string>()) .ReturnsNull(); var request = new GetCommandVariableRequest { VariableName = TestCommandVariableName }; // Act / Assert var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Get(request)); exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString()); exception.Message.Should().Be("Command Variable TestCommandVariable not found"); }
public async Task It_Should_Get_CommandVariable() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()) .Returns(new Step()); commandRepository.Get(Arg.Any <ulong>(), Arg.Any <string>()) .Returns(new Command()); var commandVariable = CommandVariables.ConnectionString; commandRepository.GetCommandVariable(Arg.Any <ulong>(), Arg.Any <string>()) .Returns(commandVariable); var request = new GetCommandVariableRequest(); // Act var response = await Sut.Get(request); // Assert response.Should().BeEquivalentTo(TestData.DomainModels.CommandVariables.ConnectionString, o => o.ExcludingMissingMembers()); response.VariableName.Should().Be(TestData.DomainModels.CommandVariables.ConnectionString.Name); }
public async Task <GetCommandVariableResponse> Get(GetCommandVariableRequest 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 commandVariable = await commandRepository.GetCommandVariable(command.Id, request.VariableName); if (commandVariable == null) { throw Err.CommandVariableNotFound(request.VariableName); } return(commandVariable.ConvertTo <GetCommandVariableResponse>()); }
public void Get_CommandVariable_Should_Throw_With_Invalid_Batch_Id() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(false); var request = new GetCommandVariableRequest { 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"); }