Exemplo n.º 1
0
        public void SaveModifiedMockEntitiesTest()
        {
            DataProviderBase mockRepos = new MemoryDataProvider();

            // load mock data
            var table = ((MemoryDataProvider)mockRepos).AddTable("mock_table");

            PopulateMockTable(table);

            var myMockEntityQuery = DataModel <MockPoco>
                                    .NewQuery()
                                    .WhereColumn["customentity_id"].IsGreaterThan(-1);

            var entities = mockRepos.LoadModels(myMockEntityQuery);

            entities[0].Entity.MockStringValue = "jkl";
            entities[1].Entity.MockStringValue = "mno";
            entities[2].Entity.MockStringValue = "pqr";
            entities.Save();

            entities = mockRepos.LoadModels(myMockEntityQuery);
            Assert.IsTrue(entities[0].Entity.MockStringValue == "jkl");
            Assert.IsTrue(entities[1].Entity.MockStringValue == "mno");
            Assert.IsTrue(entities[2].Entity.MockStringValue == "pqr");
        }
Exemplo n.º 2
0
        public void DeleteEntitiesTest()
        {
            DataProviderBase mockRepos = new MemoryDataProvider();

            // load mock data
            var table = ((MemoryDataProvider)mockRepos).AddTable("mock_table");

            PopulateMockTable(table);

            var myMockEntityQuery = DataModel <MockPoco>
                                    .NewQuery()
                                    .WhereColumn["customentity_id"].IsGreaterThan(-1);

            var entities = mockRepos.LoadModels(myMockEntityQuery);

            entities[0].MarkDeleted = true;
            entities[2].MarkDeleted = true;
            entities.Save();

            entities = mockRepos.LoadModels(myMockEntityQuery);
            Assert.IsTrue(entities.Count == 2);
        }