public async Task ExecuteNonQueryAsync_PassNullToNonOptionalParameter()
        {
            SqlProgram <XElement> program =
                await SqlProgram <XElement> .Create((Connection)DifferentLocalDatabaseConnectionString, "spTakesXml");

            // ReSharper disable once RedundantArgumentDefaultValue, ArgumentsStyleLiteral
            await program.ExecuteNonQueryAsync(p1Value : null);
        }
        public async Task ExecuteNonQueryAsync_ExecutesSuccessfully()
        {
            SqlProgram nonQueryTest = await SqlProgram.Create((Connection)LocalDatabaseConnectionString, name : "spNonQuery");

            Task <int> nonQueryResult = nonQueryTest.ExecuteNonQueryAsync();

            Assert.IsNotNull(nonQueryResult);
            nonQueryResult.Wait();
            Assert.AreEqual(-1, nonQueryResult.Result);
        }
        public async Task ExecuteNonQueryAsync_ExecutesProcedureSuccessfully()
        {
            SqlProgram <int> timeoutTest =
                await SqlProgram <int> .Create((Connection)DifferentLocalDatabaseConnectionString, "spTimeoutTest");

            Task <int> task = timeoutTest.ExecuteNonQueryAsync();

            task.Wait();
            Assert.IsTrue(task.IsCompleted);
        }
        public async Task ExecuteNonQueryAsync_WithParameters_ExecutesSuccessfully()
        {
            SqlProgram <string, int> nonQueryTest = await SqlProgram <string, int> .Create((Connection)LocalDatabaseConnectionString, name : "spNonQuery");

            Task <int> nonQueryResult = nonQueryTest.ExecuteNonQueryAsync(
                c =>
            {
                c.SetParameter("@stringParam", Random.RandomString(20));
                c.SetParameter("@intParam", Random.RandomInt32());
            });

            nonQueryResult.Wait();
            Assert.AreEqual(-1, nonQueryResult.Result);
        }
        public async Task ExecuteNonQueryAsync_WithOutputParametersNull_ThrowsException()
        {
            SqlProgram <int?, Out <int?>, Out <int> > program =
                await SqlProgram <int?, Out <int?>, Out <int> > .Create((Connection)LocalDatabaseConnectionString, "spOutputParameters");

            Out <int?> inputOutput = new Out <int?>(null);
            Out <int>  output      = new Out <int>();

            int nonQueryResult = await program.ExecuteNonQueryAsync(null, null, output);

            Assert.AreEqual(-1, nonQueryResult);

            Assert.IsNull(inputOutput.OutputError, inputOutput.OutputError?.Message);
            Assert.IsInstanceOfType(output.OutputError, typeof(InvalidCastException));

            Assert.AreEqual(null, inputOutput.OutputValue.Value);
            Assert.AreEqual(null, output.OutputValue.Value);
        }
        public async Task ExecuteNonQueryAsync_WithOutputParameters_ExecutesSuccessfully()
        {
            SqlProgram <int, Out <int>, Out <int> > program =
                await SqlProgram <int, Out <int>, Out <int> > .Create((Connection)LocalDatabaseConnectionString, "spOutputParameters");

            const int inputVal       = 123;
            const int inputOutputVal = 321;

            Out <int> inputOutput = new Out <int>(inputOutputVal);
            Out <int> output      = new Out <int>();

            int nonQueryResult = await program.ExecuteNonQueryAsync(inputVal, inputOutput, output);

            Assert.AreEqual(-1, nonQueryResult);

            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);
        }