// methods and properties public QueryDefinitionCollection GetQueryDefinitions() { QueryDefinitionCollection queries = new QueryDefinitionCollection(); FillQueryDefinitions(queries); return(queries); }
public void Merge() { QueryDefinition query1 = new QueryDefinition("id1", TestDomainStorageProviderDefinition, "bla", QueryType.Collection); QueryDefinition query2 = new QueryDefinition("id2", TestDomainStorageProviderDefinition, "bla", QueryType.Collection); QueryDefinition query3 = new QueryDefinition("id3", TestDomainStorageProviderDefinition, "bla", QueryType.Collection); QueryDefinition query4 = new QueryDefinition("id4", TestDomainStorageProviderDefinition, "bla", QueryType.Collection); QueryDefinition query5 = new QueryDefinition("id5", TestDomainStorageProviderDefinition, "bla", QueryType.Collection); QueryDefinitionCollection source = new QueryDefinitionCollection(); source.Add(query1); source.Add(query2); QueryDefinitionCollection target = new QueryDefinitionCollection(); target.Add(query3); target.Add(query4); target.Add(query5); target.Merge(source); Assert.That(source.Count, Is.EqualTo(2)); Assert.That(source[0], Is.SameAs(query1)); Assert.That(source[1], Is.SameAs(query2)); Assert.That(target.Count, Is.EqualTo(5)); Assert.That(target[0], Is.SameAs(query3)); Assert.That(target[1], Is.SameAs(query4)); Assert.That(target[2], Is.SameAs(query5)); Assert.That(target[3], Is.SameAs(query1)); Assert.That(target[4], Is.SameAs(query2)); }
private void FillQueryDefinitions(QueryDefinitionCollection queries) { XmlNodeList queryNodeList = Document.SelectNodes(FormatXPath("{0}:queries/{0}:query"), NamespaceManager); foreach (XmlNode queryNode in queryNodeList) { queries.Add(GetQueryDefinition(queryNode)); } }
public void Load_ProviderFromUndefinedStorageGroup() { QueryConfigurationLoader loader = new QueryConfigurationLoader(@"QueriesForStorageGroupTest.xml", _storageProviderDefinitionFinder); QueryDefinitionCollection queries = loader.GetQueryDefinitions(); Assert.That( queries["QueryFromUndefinedStorageGroup"].StorageProviderDefinition, Is.SameAs(DomainObjectsConfiguration.Current.Storage.DefaultStorageProviderDefinition)); }
public void Loading() { QueryConfigurationLoader loader = new QueryConfigurationLoader(@"QueriesForLoaderTest.xml", _storageProviderDefinitionFinder); QueryDefinitionCollection actualQueries = loader.GetQueryDefinitions(); QueryDefinitionCollection expectedQueries = CreateExpectedQueryDefinitions(); QueryDefinitionChecker checker = new QueryDefinitionChecker(); checker.Check(expectedQueries, actualQueries); }
public void Check(QueryDefinitionCollection expectedQueries, QueryDefinitionCollection actualQueries) { Assert.AreEqual(expectedQueries.Count, actualQueries.Count, "Number of queries does not match."); foreach (QueryDefinition expectedQuery in expectedQueries) { QueryDefinition actualQuery = actualQueries[expectedQuery.ID]; CheckQuery(expectedQuery, actualQuery); } }
private QueryDefinitionCollection CreateExpectedQueryDefinitions() { QueryDefinitionCollection queries = new QueryDefinitionCollection(); queries.Add(TestQueryFactory.CreateOrderQueryWithCustomCollectionType()); queries.Add(TestQueryFactory.CreateOrderQueryDefinitionWithObjectListOfOrder()); queries.Add(TestQueryFactory.CreateCustomerTypeQueryDefinition()); queries.Add(TestQueryFactory.CreateOrderSumQueryDefinition()); return(queries); }
public void GetDefinitions() { QueryConfiguration configuration = new QueryConfiguration("QueriesForLoaderTest.xml"); QueryConfigurationLoader loader = new QueryConfigurationLoader(@"QueriesForLoaderTest.xml", _storageProviderDefinitionFinder); QueryDefinitionCollection expectedQueries = loader.GetQueryDefinitions(); QueryDefinitionChecker checker = new QueryDefinitionChecker(); checker.Check(expectedQueries, configuration.QueryDefinitions); }
private void AreEqual(QueryDefinitionCollection expected, QueryDefinitionCollection actual) { Assert.That(ReferenceEquals(expected, actual), Is.False); Assert.That(actual, Is.Not.Null); Assert.That(actual.Count, Is.EqualTo(expected.Count)); for (int i = 0; i < expected.Count; i++) { AreEqual(expected[i], actual[i]); } }
public override void SetUp() { base.SetUp(); _collection = new QueryDefinitionCollection(); _definition = new QueryDefinition( "OrderQuery", TestDomainStorageProviderDefinition, "select Order.* from Order inner join Customer where Customer.ID = @customerID order by OrderNo asc;", QueryType.Collection, typeof(OrderCollection)); }
public void QueryDefinitionCollection() { QueryDefinitionCollection queryDefinitions = new QueryDefinitionCollection(); queryDefinitions.Add(DomainObjectsConfiguration.Current.Query.QueryDefinitions[0]); queryDefinitions.Add(DomainObjectsConfiguration.Current.Query.QueryDefinitions[1]); QueryDefinitionCollection deserializedQueryDefinitions = (QueryDefinitionCollection)SerializeAndDeserialize(queryDefinitions); AreEqual(queryDefinitions, deserializedQueryDefinitions); Assert.That(DomainObjectsConfiguration.Current.Query.QueryDefinitions[0], Is.SameAs(deserializedQueryDefinitions[0])); Assert.That(DomainObjectsConfiguration.Current.Query.QueryDefinitions[1], Is.SameAs(deserializedQueryDefinitions[1])); }
public void GetDefinitions_WithMultipleFiles() { QueryConfiguration configuration = new QueryConfiguration("QueriesForLoaderTest.xml", "QueriesForLoaderTest2.xml"); QueryConfigurationLoader loader1 = new QueryConfigurationLoader(@"QueriesForLoaderTest.xml", _storageProviderDefinitionFinder); QueryConfigurationLoader loader2 = new QueryConfigurationLoader(@"QueriesForLoaderTest2.xml", _storageProviderDefinitionFinder); QueryDefinitionCollection expectedQueries = loader1.GetQueryDefinitions(); expectedQueries.Merge(loader2.GetQueryDefinitions()); Assert.That(expectedQueries.Count > loader1.GetQueryDefinitions().Count, Is.True); QueryDefinitionChecker checker = new QueryDefinitionChecker(); checker.Check(expectedQueries, configuration.QueryDefinitions); }
public void Merge_ThrowsOnDuplicates() { QueryDefinition query1 = new QueryDefinition("id1", TestDomainStorageProviderDefinition, "bla", QueryType.Collection); QueryDefinition query2 = new QueryDefinition("id1", TestDomainStorageProviderDefinition, "bla", QueryType.Collection); QueryDefinitionCollection source = new QueryDefinitionCollection(); source.Add(query1); QueryDefinitionCollection target = new QueryDefinitionCollection(); target.Add(query2); target.Merge(source); Assert.That(target.Count, Is.EqualTo(1)); Assert.That(target[0], Is.SameAs(query2)); Assert.Fail(); }