public void ManyToOneReferenceTest() { var driver = new Driver() { Name = "Speed Racer" }; driver.Vehicles.AddRange( new Vehicle[] { new Vehicle() { Model = "Super Fast" }, new Vehicle() { Model = "Sorta Fast" } }); var Order = new Order() { Number = "1234", Driver = driver }; var store = new SQLiteDataStore("test.sqlite"); store.AddType <Order>(); store.AddType <Driver>(); store.AddType <Vehicle>(); store.CreateStore(); store.Insert(Order, true); }
public void SingleEntityFetchTest() { var drivers = new Driver[] { new Driver() { Name = "Speed Racer" }, new Driver() { Name = "Shaggy" }, new Driver() { Name = "Mario" }, new Driver() { Name = "Luigi" }, }; var store = new SQLiteDataStore("test.sqlite"); store.AddType <Driver>(); store.CreateStore(); foreach (var driver in drivers) { store.Insert(driver); } var items = store.Fetch <Driver>(2).ToArray(); Assert.AreEqual(2, items.Length); }
public void SimpleCRUDTest() { var store = new SQLiteDataStore("test.db"); store.AddType <TestItem>(); store.CreateStore(); var itemA = new TestItem("ItemA"); var itemB = new TestItem("ItemB"); var itemC = new TestItem("ItemC"); // INSERT store.Insert(itemA); store.Insert(itemB); store.Insert(itemC); // COUNT var count = store.Count <TestItem>(); Assert.AreEqual(3, count); // SELECT var item = store.Select <TestItem>("Name", itemB.Name).FirstOrDefault(); Assert.IsTrue(item.Equals(itemB)); item = store.Select <TestItem>(3); Assert.IsTrue(item.Equals(itemC)); // FETCH // UPDATE itemC.Name = "NewItem"; itemC.Address = "Changed Address"; itemC.TS = new TimeSpan(8, 23, 30); store.Update(itemC); item = store.Select <TestItem>("Name", "ItemC").FirstOrDefault(); Assert.IsNull(item); item = store.Select <TestItem>("Name", itemC.Name).FirstOrDefault(); Assert.IsTrue(item.Equals(itemC)); // CONTAINS var exists = store.Contains(itemA); Assert.IsTrue(exists); // DELETE store.Delete(itemA, false); item = store.Select <TestItem>("Name", itemA.Name).FirstOrDefault(); Assert.IsNull(item); // CONTAINS exists = store.Contains(itemA); Assert.IsFalse(exists); // COUNT count = store.Count <TestItem>(); Assert.AreEqual(2, count); }
public void LongIDTest() { var store = new SQLiteDataStore("test2.db"); store.AddType <BigID>(); store.CreateStore(); store.Insert(new BigID("Foo")); var bid = store.Select <BigID>(); }
public void DisposalTest() { try { var path = Path.Combine(TestContext.TestResultsDirectory, "test.sqlite"); var store = new SQLiteDataStore(path); store.CreateStore(); store.Dispose(); var fs = new FileStream(path, FileMode.Open); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void SimpleGuidIDEntityTest() { var store = new SQLiteDataStore("test.db"); store.AddType <GuidItem>(); store.CreateStore(); var item = new GuidItem(); store.Insert(item); var existing = store.Select <GuidItem>(item.ID); Assert.IsNotNull(existing); Assert.AreEqual(item.ID, existing.ID); store.Delete <GuidItem>(item.ID); existing = store.Select <GuidItem>(item.ID); Assert.IsNull(existing); }
private SQLiteDataStore GetTestStore() { // var info = new MySQLConnectionInfo("192.168.10.246", 3306, "TestDB", "root", "password"); var store = new SQLiteDataStore("test.db"); if (store.StoreExists) { store.DeleteStore(); } if (!store.StoreExists) { store.CreateStore(); } else { store.EnsureCompatibility(); } return(store); }
public void SimpleCRUDTest() { var path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "test.db"); var store = new SQLiteDataStore(path); store.AddType <TestItem>(); TestItem itemA; TestItem itemB; TestItem itemC; if (store.StoreExists) { store.DeleteStore(); } store.CreateStore(); itemA = new TestItem("ItemA"); itemB = new TestItem("ItemB"); itemC = new TestItem("ItemC"); // INSERT store.Insert(itemA); store.Insert(itemB); store.Insert(itemC); // COUNT var count = store.Count <TestItem>(); //Assert.AreEqual(3, count); if (count != 3) { Debugger.Break(); } // SELECT var item = store.Select <TestItem>("Name", itemB.Name).FirstOrDefault(); //Assert.IsTrue(item.Equals(itemB)); item = store.Select <TestItem>(3); //Assert.IsTrue(item.Equals(itemC)); // FETCH // UPDATE itemC.Name = "NewItem"; itemC.Address = "Changed Address"; itemC.TS = new TimeSpan(8, 23, 30); store.Update(itemC); item = store.Select <TestItem>("Name", "ItemC").FirstOrDefault(); //Assert.IsNull(item); item = store.Select <TestItem>("Name", itemC.Name).FirstOrDefault(); //Assert.IsTrue(item.Equals(itemC)); // CONTAINS var exists = store.Contains(itemA); //Assert.IsTrue(exists); // DELETE store.Delete(itemA); item = store.Select <TestItem>("Name", itemA.Name).FirstOrDefault(); //Assert.IsNull(item); // CONTAINS exists = store.Contains(itemA); //Assert.IsFalse(exists); // COUNT count = store.Count <TestItem>(); //Assert.AreEqual(2, count); }