コード例 #1
0
        private static IEnumerable <TestCaseData> QueryProcedureIfCases()
        {
            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(true, "text"),
                             new[] { new SqlQueryCommand("text", new DbParameter[0], CommandType.StoredProcedure) }));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(true, "text", parameters: null),
                             new[] { new SqlQueryCommand("text", new DbParameter[0], CommandType.StoredProcedure) }));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(true, "text", new { }),
                             new[] { new SqlQueryCommand("text", new DbParameter[0], CommandType.StoredProcedure) }));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(true, "text", new { Parameter = new SqlParameterValueStub() }),
                             new[]
            {
                new SqlQueryCommand("text", new[]
                {
                    new SqlParameterValueStub().ToDbParameter("@Parameter")
                }, CommandType.StoredProcedure)
            }));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(true, "text",
                                                   new { Parameter1 = new SqlParameterValueStub(), Parameter2 = new SqlParameterValueStub() }),
                             new[]
            {
                new SqlQueryCommand("text", new[]
                {
                    new SqlParameterValueStub().ToDbParameter("@Parameter1"),
                    new SqlParameterValueStub().ToDbParameter("@Parameter2")
                }, CommandType.StoredProcedure)
            }));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(false, "text"),
                             new SqlQueryCommand[0]));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(false, "text", parameters: null),
                             new SqlQueryCommand[0]));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(false, "text", new { }),
                             new SqlQueryCommand[0]));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(false, "text", new { Parameter = new SqlParameterValueStub() }),
                             new SqlQueryCommand[0]));

            yield return(new TestCaseData(
                             TSql.QueryProcedureIf(false, "text", new { Parameter1 = new SqlParameterValueStub(), Parameter2 = new SqlParameterValueStub() }),
                             new SqlQueryCommand[0]));
        }