public void Should_replace_where_with_included_databases() { var queryType = new SqlServerConnections(); var sqlServer = new SqlServerEndpoint("foo", "foo", false, new[] {new Database {Name = "bar"},}, null); var queryLocator = new QueryLocator(null); IEnumerable<SqlQuery> queries = queryLocator.PrepareQueries(new[] {queryType.GetType()}, false); foreach (SqlQuery query in queries) { string actual = queryType.ParameterizeQuery(query.CommandText, sqlServer); Assert.That(actual, Is.StringContaining("AND (d.Name IN ('bar')")); } }
public void Should_replace_where_with_excluded_databases() { var queryType = new SqlServerConnections(); var sqlServer = new SqlServer("foo", "foo", true, null, new[] {"blah"}); var queryLocator = new QueryLocator(null); var queries = queryLocator.PrepareQueries(new[] {queryType.GetType()}, false); foreach (var query in queries) { var actual = queryType.ParameterizeQuery(query.CommandText, sqlServer); Assert.That(actual, Is.StringContaining("AND (d.Name NOT IN ('blah')")); } }
public void Should_replace_where_with_excluded_databases() { var queryType = new SqlServerConnections(); var sqlServer = new SqlServerEndpoint("foo", "foo", true, null, new[] { "blah" }); var queryLocator = new QueryLocator(null); IEnumerable <SqlQuery> queries = queryLocator.PrepareQueries(new[] { queryType.GetType() }, false); foreach (SqlQuery query in queries) { string actual = queryType.ParameterizeQuery(query.CommandText, sqlServer); Assert.That(actual, Is.StringContaining("AND (d.Name NOT IN ('blah')")); } }
public void Should_replace_where_with_excluded_databases() { var queryType = new TQuery(); var sqlServer = new SqlServerEndpoint("foo", "foo", true, null, new[] { "exclude" }); var queryLocator = new QueryLocator(null); IEnumerable <SqlQuery> queries = sqlServer.FilterQueries(queryLocator.PrepareQueries(new[] { queryType.GetType() }, false)); foreach (SqlQuery query in queries) { string actual = queryType.ParameterizeQuery(query.CommandText, sqlServer); Assert.That(actual, Is.StringContaining(ExcludedDatabaseExpectedSql)); } }
public void Should_replace_where_with_included_and_system_databases() { var queryType = new SqlServerConnections(); var sqlServer = new SqlServerEndpoint("foo", "foo", true, new[] { new Database { Name = "bar" }, }, null); var queryLocator = new QueryLocator(null); IEnumerable <SqlQuery> queries = queryLocator.PrepareQueries(new[] { queryType.GetType() }, false); foreach (SqlQuery query in queries) { string actual = queryType.ParameterizeQuery(query.CommandText, sqlServer); Assert.That(actual, Is.StringContaining("AND (d.Name IN ('bar', 'tempdb', 'master', 'model', 'msdb')")); } }