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 WhenPassingEnlistTrue_EnlistBecomesFalse()
        {
            var cnInfo = new SqlCe4ConnectionInfo(@"data source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=True");

            Assert.AreEqual(@"Data Source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=False", cnInfo.ServerConnectionString);
            Assert.AreEqual(@"Data Source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=False", cnInfo.ClientConnectionString);
        }
        public void Ctor_WhenPassingDataSourceWithFilePath_NameIsExtracted()
        {
            var cnString = new ConnectionString(@"sisodb:provider=SqlCe4||plain:data source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;");

            var cnInfo = new SqlCe4ConnectionInfo(cnString);

            Assert.AreEqual("SisoDbTestsTemp", cnInfo.DbName);
        }
        public void Ctor_WhenCnStringWithOnlyPlainPart_InstanceWithDefaultsIsCreated()
        {
            var cnString = new ConnectionString(@"data source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;");

            var cnInfo = new SqlCe4ConnectionInfo(cnString);

            Assert.AreEqual(StorageProviders.SqlCe4, cnInfo.ProviderType);
            Assert.AreEqual(BackgroundIndexing.Off, cnInfo.BackgroundIndexing);
        }
        public void Ctor_WhenPassingDataSourceWithDataDirectory_ItRocks()
        {
            var cnString = new ConnectionString(@"sisodb:provider=SqlCe4||plain:data source=|DataDirectory|SisoDbTestsTemp.sdf;");

            var cnInfo = new SqlCe4ConnectionInfo(cnString);

            Assert.AreEqual(StorageProviders.SqlCe4, cnInfo.ProviderType);
            Assert.AreEqual("SisoDbTestsTemp.sdf", cnInfo.DbName);
            Assert.AreEqual(@"SisoDbTestsTemp.sdf", cnInfo.FilePath);
        }
        public void WhenPassingNormalCnString_ItRocks()
        {
            var cnInfo = new SqlCe4ConnectionInfo(@"data source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;");

            Assert.AreEqual(StorageProviders.SqlCe4, cnInfo.ProviderType);
            Assert.AreEqual(@"Data Source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=False", cnInfo.ServerConnectionString);
            Assert.AreEqual(@"Data Source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=False", cnInfo.ClientConnectionString);
            Assert.AreEqual("SisoDbTestsTemp", cnInfo.DbName);
            Assert.AreEqual(@"d:\#Temp\SisoDb\SisoDbTestsTemp.sdf", cnInfo.FilePath);
        }
        private void EnsureWarmedUp(SqlCe4ConnectionInfo connectionInfo)
        {
            if(_warmupConnections.ContainsKey(connectionInfo.FilePath))
                return;

            var cn = new SqlCeConnection(connectionInfo.ServerConnectionString);
            if(!_warmupConnections.TryAdd(connectionInfo.FilePath, cn))
            {
                cn.Close();
                cn.Dispose();
            }
        }
        public void Ctor_WhenCorrectConnectionString_PartsExtracted()
        {
            var cnString = new ConnectionString(@"sisodb:provider=SqlCe4;backgroundindexing=Off||plain:data source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=True");

            var cnInfo = new SqlCe4ConnectionInfo(cnString);

            Assert.AreEqual(StorageProviders.SqlCe4, cnInfo.ProviderType);
            Assert.AreEqual(BackgroundIndexing.Off, cnInfo.BackgroundIndexing);
            Assert.AreEqual("SisoDbTestsTemp", cnInfo.DbName);
            Assert.AreEqual(@"d:\#Temp\SisoDb", cnInfo.ServerPath);
            Assert.AreEqual(@"Data Source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=False", cnInfo.ServerConnectionString.PlainString);
            Assert.AreEqual(@"Data Source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=False", cnInfo.ClientConnectionString.PlainString);
        }
Example #9
0
        private void EnsureWarmedUp(SqlCe4ConnectionInfo connectionInfo)
        {
            if (_warmupConnections.ContainsKey(connectionInfo.FilePath))
            {
                return;
            }

            var cn = new SqlCeConnection(connectionInfo.ServerConnectionString);

            if (!_warmupConnections.TryAdd(connectionInfo.FilePath, cn))
            {
                cn.Close();
                cn.Dispose();
            }
        }
        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 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);

            }
        }
 public SqlCe4ServerClient(IAdoDriver driver, SqlCe4ConnectionInfo connectionInfo, IConnectionManager connectionManager, ISqlStatements sqlStatements) 
     : base(driver, connectionInfo, connectionManager, sqlStatements)
 {
     _connectionInfo = connectionInfo;
 }
        public void Ctor_WhenBackgroundIndexingIsMissing_DefaultsToOff()
        {
            var cnString = new ConnectionString(@"sisodb:provider=SqlCe4||plain:data source=d:\#Temp\SisoDb\SisoDbTestsTemp.sdf;Enlist=True");

            var cnInfo = new SqlCe4ConnectionInfo(cnString);

            Assert.AreEqual(BackgroundIndexing.Off, cnInfo.BackgroundIndexing);
        }
        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());
            }
        }
Example #16
0
 public SqlCe4ServerClient(IAdoDriver driver, SqlCe4ConnectionInfo connectionInfo, IConnectionManager connectionManager, ISqlStatements sqlStatements)
     : base(driver, connectionInfo, connectionManager, sqlStatements)
 {
     _connectionInfo = connectionInfo;
 }
        private static void EnsureDbExists()
        {
            var connectionInfo = new SqlCe4ConnectionInfo(TestConstants.ConnectionStringNameForSqlCe4);
        	var database = new SqlCe4DbFactory().CreateDatabase(connectionInfo);
			database.EnsureNewDatabase();
        }