Example #1
0
        public void DeepLoadEntityManyToManyTest()
        {
            var usersTable     = CreateAndPopulateMockTable("User");
            var groupsTable    = CreateAndPopulateMockTable("Group");
            var groupUserTable = CreateAndPopulateMockTable("GroupUser");

            var memProvider = new MemoryDataProvider();

            memProvider.AddTable(usersTable);
            memProvider.AddTable(groupsTable);
            memProvider.AddTable(groupUserTable);
            var query   = new DataModelQuery <DataModel <Group> >();
            var egroups = memProvider.DeepLoadModels(query);
            var groups  = new DataModelCollection <DataModel <Group> >(egroups);

            Assert.IsTrue(groups.Count == 2, "Groups did not load");
            Assert.IsNotNull(groups[0].Entity, "Group 0 Entity was not set");
            Assert.IsNotNull(groups[0].Entity.Users, "Group 0 Users were not set");
            Assert.IsTrue(groups[0].Entity.Users.Count == 2, "Users count (group 0 of 0,1) is not 2");
            Assert.IsNotNull(groups[1].Entity, "Group 1 Entity was not set");
            Assert.IsNotNull(groups[0].Entity.Users, "Group 1 Users were not set");
            Assert.IsTrue(groups[1].Entity.Users.Count == 2, "Users count (group 1 of 0,1) is not 2");

            Assert.IsTrue(groups[0].Entity.Users[0].ID
                          != groups[1].Entity.Users[0].ID, "Same user loaded between groups");
            Assert.IsTrue(groups[0].Entity.Users[0].ID
                          != groups[1].Entity.Users[1].ID, "Same user loaded between groups");
            Assert.IsTrue(groups[1].Entity.Users[0].ID
                          != groups[0].Entity.Users[0].ID, "Same user loaded between groups");
        }
Example #2
0
        public void DeepLoadEntitiesTest()
        {
            DataProviderBase mockRepos = new MemoryDataProvider();
            var table = ((MemoryDataProvider)mockRepos).AddTable("mock_table");

            PopulateMockTable(table);
            var table2 = ((MemoryDataProvider)mockRepos).AddTable("mock_table2");

            PopulateMockTable(table2);
            var query = DataModel <DataModelRelationshipMetadataTest.MockPocoChild> .NewQuery();

            DataModelCollection <DataModel <DataModelRelationshipMetadataTest.MockPocoChild> >
            entities = mockRepos.DeepLoadModels(query);

            Assert.IsNotNull(entities);
            Assert.IsTrue(entities.Count == 4);
            Assert.IsTrue(entities[0].Entity.MockPoco != null);
            Assert.IsTrue(entities[3].Entity.MockPoco != null);
            Assert.IsTrue(entities[2].Entity.MockPoco.MockDecimalValue
                          .Equals(entities[2].Entity.MockDecimalValue));
        }