예제 #1
0
        private static IEnumerable <TestCaseData> QueryStatementIfCases()
        {
            yield return(new TestCaseData(
                             TSql.QueryStatementIf(true, "text"),
                             new[] { new SqlQueryCommand("text", new DbParameter[0], CommandType.Text) }));

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

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

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

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

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

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

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

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

            yield return(new TestCaseData(
                             TSql.QueryStatementIf(false, "text", new { Parameter1 = new SqlParameterValueStub(), Parameter2 = new SqlParameterValueStub() }),
                             new SqlQueryCommand[0]));
        }
 public void QueryIfParameterCountNotLimitedTo2098WhenConditionIsNotMet()
 {
     Assert.DoesNotThrow(() => TSql.QueryStatementIf(false, "", ParameterCountLimitedExceeded.Instance).ToArray());
 }
 public void QueryIfParameterCountLimitedTo2098WhenConditionIsMet()
 {
     Assert.Throws <ArgumentException>(() => TSql.QueryStatementIf(true, "", ParameterCountLimitedExceeded.Instance).ToArray());
 }