public void QueryFormatIfParameterCountNotLimitedTo2098WhenConditionIsNotMet()
 {
     Assert.DoesNotThrow(() => TSql.QueryStatementFormatIf(false, "", ParameterCountLimitedExceeded.Instance.All).ToArray());
 }
예제 #2
0
        private static IEnumerable <TestCaseData> QueryStatementFormatIfCases()
        {
            yield return(new TestCaseData(
                             TSql.QueryStatementFormatIf(true, "text"),
                             new[] { new SqlQueryCommand("text", new DbParameter[0], CommandType.Text) }));

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

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

            yield return(new TestCaseData(
                             TSql.QueryStatementFormatIf(true, "text", new SqlParameterValueStub()),
                             new[]
            {
                new SqlQueryCommand("text", new[]
                {
                    new SqlParameterValueStub().ToDbParameter("@P0")
                }, CommandType.Text)
            }));

            yield return(new TestCaseData(
                             TSql.QueryStatementFormatIf(true, "text {0}", new SqlParameterValueStub()),
                             new[]
            {
                new SqlQueryCommand("text @P0", new[]
                {
                    new SqlParameterValueStub().ToDbParameter("@P0")
                }, CommandType.Text)
            }));

            yield return(new TestCaseData(
                             TSql.QueryStatementFormatIf(true, "text", new SqlParameterValueStub(), new SqlParameterValueStub()),
                             new[]
            {
                new SqlQueryCommand("text", new[]
                {
                    new SqlParameterValueStub().ToDbParameter("@P0"),
                    new SqlParameterValueStub().ToDbParameter("@P1")
                }, CommandType.Text)
            }));

            yield return(new TestCaseData(
                             TSql.QueryStatementFormatIf(true, "text {0} {1}", new SqlParameterValueStub(), new SqlParameterValueStub()),
                             new[]
            {
                new SqlQueryCommand("text @P0 @P1", new[]
                {
                    new SqlParameterValueStub().ToDbParameter("@P0"),
                    new SqlParameterValueStub().ToDbParameter("@P1")
                }, CommandType.Text)
            }));

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

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

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

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

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

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

            yield return(new TestCaseData(
                             TSql.QueryStatementFormatIf(false, "text {0} {1}", new SqlParameterValueStub(), new SqlParameterValueStub()),
                             new SqlQueryCommand[0]));
        }
 public void QueryFormatIfParameterCountLimitedTo2098WhenConditionIsMet()
 {
     Assert.Throws <ArgumentException>(() => TSql.QueryStatementFormatIf(true, "", ParameterCountLimitedExceeded.Instance.All).ToArray());
 }