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

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

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

            yield return(new TestCaseData(
                             TSql.NonQueryStatementIf(true, "text", new { Parameter = new TestDbParameter() }),
                             new[]
            {
                new SqlNonQueryCommand("text", new[]
                {
                    new TestDbParameter().ToDbParameter("@Parameter")
                }, CommandType.Text)
            }));

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

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

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

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

            yield return(new TestCaseData(
                             TSql.NonQueryStatementIf(false, "text", new { Parameter = new TestDbParameter() }),
                             new SqlNonQueryCommand[0]));

            yield return(new TestCaseData(
                             TSql.NonQueryStatementIf(false, "text", new { Parameter1 = new TestDbParameter(), Parameter2 = new TestDbParameter() }),
                             new SqlNonQueryCommand[0]));
        }
 public void NonQueryStatementIfParameterCountNotLimitedTo2098WhenConditionIsNotMet()
 {
     Assert.DoesNotThrow(() => TSql.NonQueryStatementIf(false, "", ParameterCountLimitedExceeded.Instance).ToArray());
 }
 public void NonQueryStatementIfParameterCountLimitedTo2098WhenConditionIsMet()
 {
     Assert.Throws <ArgumentException>(() => TSql.NonQueryStatementIf(true, "", ParameterCountLimitedExceeded.Instance).ToArray());
 }