public void AppendFilterEntry_does_not_create_comparison_for_missing_catalog_schema_or_name_if_any_specified()
        {
            Assert.Equal(
                "(alias.SchemaName LIKE @p0 AND alias.Name LIKE @p1)",
                EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                    new StringBuilder(),
                    "alias",
                    new EntityStoreSchemaFilterEntry(null, "schema", "name"),
                    new Dictionary <string, string>()).ToString());

            Assert.Equal(
                "(alias.CatalogName LIKE @p0 AND alias.Name LIKE @p1)",
                EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                    new StringBuilder(),
                    "alias",
                    new EntityStoreSchemaFilterEntry("catalog", null, "name"),
                    new Dictionary <string, string>()).ToString());

            Assert.Equal(
                "(alias.CatalogName LIKE @p0 AND alias.SchemaName LIKE @p1)",
                EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                    new StringBuilder(),
                    "alias",
                    new EntityStoreSchemaFilterEntry("catalog", "schema", null),
                    new Dictionary <string, string>()).ToString());
        }
        public void AppendComparison_creates_parameters_and_adds_AND_for_multiple_comparisons()
        {
            var parameterMap = new Dictionary <string, string>();

            var filterBuilder =
                EntityStoreSchemaQueryGenerator.AppendComparison(
                    new StringBuilder(),
                    "alias1",
                    "propertyName1",
                    "Value1",
                    parameterMap);

            EntityStoreSchemaQueryGenerator.AppendComparison(
                filterBuilder,
                "alias2",
                "propertyName2",
                "Value2",
                parameterMap);

            Assert.Equal(
                "alias1.propertyName1 LIKE @p0 AND alias2.propertyName2 LIKE @p1",
                filterBuilder.ToString());

            Assert.Equal(2, parameterMap.Count);
            Assert.Equal(parameterMap["Value1"], "p0");
            Assert.Equal(parameterMap["Value2"], "p1");
        }
        public void AppendFilterEntry_uses_OR_to_connect_multiple_filters()
        {
            var parameterMap  = new Dictionary <string, string>();
            var filterBuilder = new StringBuilder();

            EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                filterBuilder,
                "alias",
                new EntityStoreSchemaFilterEntry(null, null, null),
                parameterMap);

            EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                filterBuilder,
                "alias",
                new EntityStoreSchemaFilterEntry("catalog", "schema", null),
                parameterMap);

            Assert.Equal(
                "(alias.Name LIKE @p0) OR (alias.CatalogName LIKE @p1 AND alias.SchemaName LIKE @p2)",
                filterBuilder.ToString());

            Assert.Equal(3, parameterMap.Count);
            Assert.Equal(parameterMap["%"], "p0");
            Assert.Equal(parameterMap["catalog"], "p1");
            Assert.Equal(parameterMap["schema"], "p2");
        }
        public void AppendComparison_creates_parameters_and_adds_AND_for_multiple_comparisons()
        {
            var parameters = new EntityCommand().Parameters;

            var filterBuilder =
                EntityStoreSchemaQueryGenerator.AppendComparison(
                    new StringBuilder(),
                    "alias1",
                    "propertyName1",
                    "Value1",
                    parameters);

            EntityStoreSchemaQueryGenerator.AppendComparison(
                filterBuilder,
                "alias2",
                "propertyName2",
                "Value2",
                parameters);

            Assert.Equal(
                "alias1.propertyName1 LIKE @p0 AND alias2.propertyName2 LIKE @p1",
                filterBuilder.ToString());

            Assert.Equal(2, parameters.Count);
            Assert.Equal("p0,p1", string.Join(",", parameters.OfType <EntityParameter>().Select(p => p.ParameterName)));
            Assert.Equal("Value1,Value2", string.Join(",", parameters.OfType <EntityParameter>().Select(p => p.Value)));
        }
        public void AppendFilterEntry_uses_OR_to_connect_multiple_filters()
        {
            var parameters    = new EntityCommand().Parameters;
            var filterBuilder = new StringBuilder();

            EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                filterBuilder,
                "alias",
                new EntityStoreSchemaFilterEntry(null, null, null),
                parameters);

            EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                filterBuilder,
                "alias",
                new EntityStoreSchemaFilterEntry("catalog", "schema", null),
                parameters);

            Assert.Equal(
                "(alias.Name LIKE @p0) OR (alias.CatalogName LIKE @p1 AND alias.SchemaName LIKE @p2)",
                filterBuilder.ToString());

            Assert.Equal(3, parameters.Count);
            Assert.Equal("p0,p1,p2", string.Join(",", parameters.OfType <EntityParameter>().Select(p => p.ParameterName)));
            Assert.Equal("%,catalog,schema", string.Join(",", parameters.OfType <EntityParameter>().Select(p => p.Value)));
        }
Esempio n. 6
0
        public void AppendComparison_creates_parameters_and_adds_AND_for_multiple_comparisons()
        {
            var parameters = CreateParameters();

            var filterBuilder =
                EntityStoreSchemaQueryGenerator.AppendComparison(
                    new StringBuilder(),
                    "alias1",
                    "propertyName1",
                    "Value1",
                    parameters);

            EntityStoreSchemaQueryGenerator.AppendComparison(
                filterBuilder,
                "alias2",
                "propertyName2",
                "Value2",
                parameters);

            Assert.Equal(
                "alias1.propertyName1 LIKE @p0 AND alias2.propertyName2 LIKE @p1",
                filterBuilder.ToString());

            Assert.Equal(2, parameters.Count);
            Assert.Equal("p0", parameters[0].ParameterName);
            Assert.Equal("Value1", parameters["p0"].Value);
            Assert.Equal("Value2", parameters["p1"].Value);
        }
Esempio n. 7
0
        public void AppendFilterEntry_uses_OR_to_connect_multiple_filters()
        {
            var parameters    = CreateParameters();
            var filterBuilder = new StringBuilder();

            EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                filterBuilder,
                "alias",
                new EntityStoreSchemaFilterEntry(null, null, null),
                parameters);

            EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                filterBuilder,
                "alias",
                new EntityStoreSchemaFilterEntry("catalog", "schema", null),
                parameters);

            Assert.Equal(
                "(alias.Name LIKE @p0) OR (alias.CatalogName LIKE @p1 AND alias.SchemaName LIKE @p2)",
                filterBuilder.ToString());

            Assert.Equal(3, parameters.Count);
            Assert.Equal("p0", parameters[0].ParameterName);
            Assert.Equal("p1", parameters[1].ParameterName);
            Assert.Equal("%", parameters["p0"].Value);
            Assert.Equal("catalog", parameters["p1"].Value);
            Assert.Equal("schema", parameters["p2"].Value);
        }
 public void AppendComparison_does_not_create_comparison_fragment_or_corresponding_parameter_for_non_value()
 {
     Assert.Empty(
         EntityStoreSchemaQueryGenerator.AppendComparison(
             new StringBuilder(),
             string.Empty,
             string.Empty,
             /* value */ null,
             new Dictionary <string, string>()).ToString());
 }
        public void AppendFilterEntry_creates_filter_for_catalog_schema_and_name_if_all_specified()
        {
            var parameters = new EntityCommand().Parameters;

            Assert.Equal(
                "(alias.CatalogName LIKE @p0 AND alias.SchemaName LIKE @p1 AND alias.Name LIKE @p2)",
                EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                    new StringBuilder(),
                    "alias",
                    new EntityStoreSchemaFilterEntry("catalog", "schema", "name"),
                    parameters).ToString());

            Assert.Equal(3, parameters.Count);
        }
        public void AppendFilterEntry_uses_wildcard_parameter_value_if_schema_catalog_and_name_are_null()
        {
            var parameterMap = new Dictionary <string, string>();

            Assert.Equal(
                "(alias.Name LIKE @p0)",
                EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                    new StringBuilder(),
                    "alias",
                    new EntityStoreSchemaFilterEntry(null, null, null),
                    parameterMap).ToString());

            Assert.Equal(1, parameterMap.Count);
            Assert.Equal(parameterMap["%"], "p0");
        }
        public void AppendComparison_creates_comparison_fragment_and_corresponding_parameter_for_non_null_value()
        {
            var parameterMap = new Dictionary <string, string>();

            Assert.Equal(
                "alias.propertyName LIKE @p0",
                EntityStoreSchemaQueryGenerator.AppendComparison(
                    new StringBuilder(),
                    "alias",
                    "propertyName",
                    "Value",
                    parameterMap).ToString());

            Assert.Equal(1, parameterMap.Count);
            Assert.Equal(parameterMap["Value"], "p0");
        }
        public void AppendFilterEntry_uses_wildcard_parameter_value_if_schema_catalog_and_name_are_null()
        {
            var parameters = new EntityCommand().Parameters;

            Assert.Equal(
                "(alias.Name LIKE @p0)",
                EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                    new StringBuilder(),
                    "alias",
                    new EntityStoreSchemaFilterEntry(null, null, null),
                    parameters).ToString());

            Assert.Equal(1, parameters.Count);
            Assert.Equal("p0", parameters[0].ParameterName);
            Assert.Equal("%", parameters[0].Value);
        }
        public void AppendFilterEntry_creates_filter_for_catalog_schema_and_name_if_all_specified()
        {
            var parameterMap = new Dictionary <string, string>();

            Assert.Equal(
                "(alias.CatalogName LIKE @p0 AND alias.SchemaName LIKE @p1 AND alias.Name LIKE @p2)",
                EntityStoreSchemaQueryGenerator.AppendFilterEntry(
                    new StringBuilder(),
                    "alias",
                    new EntityStoreSchemaFilterEntry("catalog", "schema", "name"),
                    parameterMap).ToString());

            Assert.Equal(3, parameterMap.Count);
            Assert.Equal(parameterMap["catalog"], "p0");
            Assert.Equal(parameterMap["schema"], "p1");
            Assert.Equal(parameterMap["name"], "p2");
        }
        public void AppendComparison_creates_comparison_fragment_and_corresponding_parameter_for_non_null_value()
        {
            var parameters = new EntityCommand().Parameters;

            Assert.Equal(
                "alias.propertyName LIKE @p0",
                EntityStoreSchemaQueryGenerator.AppendComparison(
                    new StringBuilder(),
                    "alias",
                    "propertyName",
                    "Value",
                    parameters).ToString());

            Assert.Equal(1, parameters.Count);
            Assert.Equal("p0", parameters[0].ParameterName);
            Assert.Equal("Value", parameters[0].Value);
        }