Ejemplo n.º 1
0
        private static IEnumerable <TestCaseData> QueryStatementFormatCases()
        {
            yield return(new TestCaseData(
                             TSql.QueryStatementFormat("text"),
                             new SqlQueryCommand("text", new DbParameter[0], CommandType.Text)));

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

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

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

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

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

            yield return(new TestCaseData(
                             TSql.QueryStatementFormat("text {0} {1}", new SqlParameterValueStub(), new SqlParameterValueStub()),
                             new SqlQueryCommand("text @P0 @P1", new[]
            {
                new SqlParameterValueStub().ToDbParameter("@P0"),
                new SqlParameterValueStub().ToDbParameter("@P1")
            }, CommandType.Text)));
        }
 public void QueryFormatParameterCountLimitedTo2098()
 {
     Assert.Throws <ArgumentException>(() => TSql.QueryStatementFormat("", ParameterCountLimitedExceeded.Instance.All));
 }