public void TestMethodNestedOwners()
        {
            var cn = new SqlCe4ConnectionInfo(connectionString);
            var db = new SqlCe4DbFactory().CreateDatabase(cn);
            var keyObjectStore = new SisoDbKeyObjectStore(db);

            var ownerStore1 = keyObjectStore.GetStore("owner1");
            var ownerStore11 = ownerStore1.GetStore("owner11");
            var ownerStore12 = ownerStore1.GetStore("owner1"); // this owner1 is actually owner1.owner1

            var defaultStoreTable = ownerStore1.Table<string>("table");
            var owner1Table = ownerStore11.Table<string>("table");
            var owner2Table = ownerStore12.Table<string>("table");

            defaultStoreTable.Empty();
            owner1Table.Empty();
            owner2Table.Empty();

            owner1Table.Insert("Foo");

            var getFromDefaultStore = defaultStoreTable.All();
            var getFromOwner1 = owner1Table.All();
            var getFromOwner2 = owner2Table.All();

            Assert.AreEqual(0, getFromDefaultStore.Count());
            Assert.AreEqual(1, getFromOwner1.Count());
            Assert.AreEqual(0, getFromOwner2.Count());
        }
        public void TestMethodMultipleTables()
        {
            var cn = new SqlCe4ConnectionInfo(connectionString);
            var db = new SqlCe4DbFactory().CreateDatabase(cn);
            var keyObjectStore = new SisoDbKeyObjectStore(db);

            var table1 = keyObjectStore.Table<string>("table1");
            var table2 = keyObjectStore.Table<string>("table2");

            table1.Empty();
            table2.Empty();

            table1.Insert("foo");
            table1.Insert("bar");

            var fromTable1 = table1.All();
            var fromTable2 = table2.All();

            Assert.AreEqual(2, fromTable1.Count());
            Assert.AreEqual(0, fromTable2.Count());
        }
        public void TestMethodTable()
        {
            var cn = new SqlCe4ConnectionInfo(connectionString);
            var db = new SqlCe4DbFactory().CreateDatabase(cn);
            var keyObjectStore = new SisoDbKeyObjectStore(db);

            using (var myTable = keyObjectStore.Table<string>("myTable"))
            {

                myTable.Empty();

                var firstId = myTable.Insert("foo");
                var secondId = myTable.Insert("bar");
                var thirdId = myTable.Insert("THREE");

                var second = myTable.Select(secondId);
                Assert.AreEqual("bar", second);

                myTable.Delete(secondId);
                var secondIsDeleted = myTable.Select(secondId);

                Assert.IsNull(secondIsDeleted);

                var all = myTable.All();

                Assert.AreEqual(2, all.Count());
            }
        }
 public void TestMethodSetGetObject()
 {
     var cn = new SqlCe4ConnectionInfo(connectionString);
     var db = new SqlCe4DbFactory().CreateDatabase(cn);
     var x = new SisoDbKeyObjectStore(db);
     x.Store("foo", "foo");
     var s = x.Get<string>("foo");
     Assert.AreEqual("foo", s);
 }
        public void TestMethodTypedTable()
        {
            var cn = new SqlCe4ConnectionInfo(connectionString);
            var db = new SqlCe4DbFactory().CreateDatabase(cn);
            var keyObjectStore = new SisoDbKeyObjectStore(db);

            using (var myTable = keyObjectStore.Table<SomeType>()) // stored in "SomeType" by default
            {

                myTable.Empty();

                var firstId = myTable.Insert(new SomeType { SomeValue = 100, SomeGuid = Guid.NewGuid(), SomeOtherValue = 1.1M });
                var secondId = myTable.Insert(new SomeType { SomeValue = 200, SomeGuid = Guid.NewGuid(), SomeOtherValue = 2.2M });
                var thirdId = myTable.Insert(new SomeType { SomeValue = 300, SomeGuid = Guid.NewGuid(), SomeOtherValue = 3.3M });

                var second = myTable.Select(secondId);

                Assert.AreEqual(200, second.SomeValue);
                Assert.AreEqual(2.2M, second.SomeOtherValue);
                Assert.AreEqual(400, second.SomeFunction());

                var all = myTable.All();
                var sum = all.Sum(t => t.SomeOtherValue);

                Assert.AreEqual(6.6M, sum);

            }
        }
        private static void EnsureDbExists()
        {
            var connectionInfo = new SqlCe4ConnectionInfo(TestConstants.ConnectionStringNameForSqlCe4);
        	var database = new SqlCe4DbFactory().CreateDatabase(connectionInfo);
			database.EnsureNewDatabase();
        }