public async Task ExecuteNonQueryAllAsync_WithOutputParametersAndMultiOut_ExecutesSuccessfully() { SqlProgram <int, Out <int>, Out <int> > program = await SqlProgram <int, Out <int>, Out <int> > .Create( new LoadBalancedConnection(LocalDatabaseConnectionString, LocalDatabaseCopyConnectionString), "spOutputParameters"); const int inputVal = 123; const int inputOutputVal = 321; MultiOut <int> inputOutput = new MultiOut <int>(inputOutputVal); MultiOut <int> output = new MultiOut <int>(); int[] nonQueryResult = (await program.ExecuteNonQueryAllAsync(inputVal, inputOutput, output)).ToArray(); Assert.AreEqual(2, nonQueryResult.Length); Assert.IsTrue(nonQueryResult.All(i => i == -1)); Assert.IsNull(inputOutput.OutputError, inputOutput.OutputError?.Message); Assert.IsNull(output.OutputError, output.OutputError?.Message); Assert.AreEqual(inputOutputVal * 2, inputOutput.OutputValue.Value); Assert.AreEqual(inputVal, output.OutputValue.Value); Assert.IsTrue(inputOutput.All(o => o.OutputValue.Value == inputOutputVal * 2)); Assert.IsTrue(output.All(o => o.OutputValue.Value == inputVal)); }
public async Task ExecuteXmlReaderAllAsync_WithOutputParametersAndMultiOut_ExecutesSuccessfully() { SqlProgram <int, Out <int>, Out <int> > program = await SqlProgram <int, Out <int>, Out <int> > .Create( new LoadBalancedConnection(LocalDatabaseConnectionString, LocalDatabaseCopyConnectionString), "spOutputParameters"); const int inputVal = 123; const int inputOutputVal = 321; MultiOut <int> inputOutput = new MultiOut <int>(inputOutputVal); MultiOut <int> output = new MultiOut <int>(); XElement[] result = (await program.ExecuteXmlReaderAllAsync( async(reader, token) => XElement.Load(reader), inputVal, inputOutput, output)).ToArray(); Assert.AreEqual(2, result.Length); Assert.IsTrue(result.All(i => i.ToString() == "<foo>bar</foo>")); Assert.IsNull(inputOutput.OutputError, inputOutput.OutputError?.Message); Assert.IsNull(output.OutputError, output.OutputError?.Message); Assert.AreEqual(inputOutputVal * 2, inputOutput.OutputValue.Value); Assert.AreEqual(inputVal, output.OutputValue.Value); Assert.IsTrue(inputOutput.All(o => o.OutputValue.Value == inputOutputVal * 2)); Assert.IsTrue(output.All(o => o.OutputValue.Value == inputVal)); }
public async Task ExecuteScalarAll_WithOutputParametersAndMultiOut_ExecutesSuccessfully() { SqlProgram <int, Out <int>, Out <int> > program = await SqlProgram <int, Out <int>, Out <int> > .Create( new LoadBalancedConnection(LocalDatabaseConnectionString, LocalDatabaseCopyConnectionString), "spOutputParameters"); const int inputVal = 123; const int inputOutputVal = 321; MultiOut <int> inputOutput = new MultiOut <int>(inputOutputVal); MultiOut <int> output = new MultiOut <int>(); string[] scalarResult = program.ExecuteScalarAll <string>(inputVal, inputOutput, output).ToArray(); Assert.AreEqual(2, scalarResult.Length); Assert.IsTrue(scalarResult.All(i => i == "<foo>bar</foo>")); Assert.IsNull(inputOutput.OutputError, inputOutput.OutputError?.Message); Assert.IsNull(output.OutputError, output.OutputError?.Message); Assert.AreEqual(inputOutputVal * 2, inputOutput.OutputValue.Value); Assert.AreEqual(inputVal, output.OutputValue.Value); Assert.IsTrue(inputOutput.All(o => o.OutputValue.Value == inputOutputVal * 2)); Assert.IsTrue(output.All(o => o.OutputValue.Value == inputVal)); }