public void TEST_no_caching() { var DatabaseService = new DatabaseService(null, "TestDB" + Guid.NewGuid().ToString(), null, null, null); DatabaseService.DataBaseSettings.MaxResponseTime = TimeSpan.FromMinutes(5); for (int i = 0; i < 100; i++) { StorageDatabase <Finance <object>, object> fin = DatabaseService.Documents <Finance <object>, object>(); StorageDatabase <History <object>, object> History = DatabaseService.Documents <History <object>, object>(); fin.LoadAll(true).ToList().ForEach( x => { fin.Delete(x.Id); fin.DeleteForever(x.Id); }); History.LoadAll(true).ToList().ForEach( x => { History.Delete(x.Id); History.DeleteForever(x.Id); }); IEnumerable <Finance <object> > allx = fin.LoadAll(true); Finance <object> data = fin.Create(new Finance <object>()); IEnumerable <Finance <object> > allk = fin.LoadAll(true); IEnumerable <Finance <object> > allhhjjw = fin.LoadAll(true); data.FileContent = "bla"; IEnumerable <Finance <object> > allhhw = fin.LoadAll(true); fin.Update(data); IEnumerable <Finance <object> > allw = fin.LoadAll(true); History <object> h = History.Load(History.LoadAll(true).LastOrDefault().Id); data = fin.Load(data.Id); IEnumerable <Finance <object> > ally = fin.LoadAll(true); TestHelperMethods.AssertAwait( () => { IEnumerable <Finance <object> > all = fin.LoadAll(true); Assert.AreEqual(1, all.Count()); }); fin.Delete(data.Id); h = History.Load(History.LoadAll(true).Last().Id); DbStats stats = SystemDbService.GetSystemStatistics(DatabaseService, x => x.DocumentName != typeof(History <object>).Name); fin.DeleteForever(data.Id); h = History.Load(History.LoadAll(true).LastOrDefault().Id); stats = SystemDbService.GetSystemStatistics(DatabaseService, x => x.DocumentName != typeof(History <object>).Name); TestHelperMethods.AssertAwait(() => Assert.AreEqual(0, fin.LoadAll(true).Count())); } }
public void TestMethod1() { var DatabaseService = new DatabaseService(null, "TestDB" + Guid.NewGuid().ToString(), null, null, null); StorageDatabase <Finance <object>, object> fin = DatabaseService.Documents <Finance <object>, object>(); StorageDatabase <History <object>, object> History = DatabaseService.Documents <History <object>, object>(); IEnumerable <History <object> > h = History.LoadAll(true); IEnumerable <Finance <object> > f = fin.LoadAll(true); Finance <object> mod = fin.Create( new Finance <object> { FileName = "shdlkhslkdhlksd" }); h = History.LoadAll(true); IEnumerable <Finance <object> > f1 = fin.LoadAll(); DbStats t = SystemDbService.GetSystemStatistics(DatabaseService); DbStats q = SystemDbService.GetSystemStatistics(DatabaseService, x => x.LastOperation == "CREATE"); foreach (Finance <object> id in f1) { Finance <object> d = fin.Load(id.Id); fin.Delete(id.Id); fin.DeleteForever(id.Id); } h = History.LoadAll(true); f = fin.LoadAll(true); IEnumerable <History <object> > h1 = History.LoadAll(); foreach (History <object> id in h1) { History <object> d = History.Load(id.Id); History.Delete(id.Id); History.DeleteForever(id.Id); } h = History.LoadAll(true); f = fin.LoadAll(true); t = SystemDbService.GetSystemStatistics(DatabaseService); }
public void TEST_with_caching_inmemory() { var DatabaseService = new DatabaseService(null, "TestDB" + Guid.NewGuid().ToString(), null, null, null); for (int i = 0; i < 100; i++) { DatabaseService.DataBaseSettings.EnableFasterCachingButWithLeakyUpdates = true; StorageDatabase <Finance <object>, object> fin = DatabaseService.Documents <Finance <object>, object>(); StorageDatabase <History <object>, object> History = DatabaseService.Documents <History <object>, object>(); fin.LoadAll(true).ToList().ForEach( x => { fin.Delete(x.Id); fin.DeleteForever(x.Id); }); History.LoadAll(true).ToList().ForEach( x => { History.Delete(x.Id); History.DeleteForever(x.Id); }); Finance <object> data = fin.Create(new Finance <object>()); data.FileContent = "bla"; fin.Update(data); History <object> h = History.Load(History.LoadAll(true).LastOrDefault().Id); data = fin.Load(data.Id); TestHelperMethods.AssertAwait(() => Assert.AreEqual(1, fin.LoadAll(true).Count())); fin.Delete(data.Id); h = History.Load(History.LoadAll(true).Last().Id); DbStats stats = SystemDbService.GetSystemStatistics(DatabaseService, x => x.DocumentName != typeof(History <object>).Name); fin.DeleteForever(data.Id); h = History.Load(History.LoadAll(true).LastOrDefault().Id); stats = SystemDbService.GetSystemStatistics(DatabaseService, x => x.DocumentName != typeof(History <object>).Name); TestHelperMethods.AssertAwait(() => Assert.AreEqual(0, fin.LoadAll(true).Count())); } }
public void transaction() { var DatabaseService = new DatabaseService(null, "TestDB" + Guid.NewGuid().ToString(), null, null, null); DatabaseService.DataBaseSettings.MaxResponseTime = TimeSpan.FromMinutes(10); StorageDatabase <Finance <object>, object> fin = DatabaseService.Documents <Finance <object>, object>(); fin.LoadAll(true).ToList().ForEach( x => { fin.Delete(x.Id); fin.DeleteForever(x.Id); }); TestHelperMethods.AssertAwait(() => Assert.AreEqual(0, fin.LoadAll(true).Count())); int total = 100; Task.Run( () => { DatabaseService.Transaction( handle => { for (int i = 0; i < total; i++) { Finance <object> ti = handle.GetDBRef <Finance <object>, object>().Create(new Finance <object>()); } return(true); }); }); IEnumerable <Finance <object> > t = fin.LoadAll(true); TestHelperMethods.AssertAwait(1000); fin.Create(new Finance <object>()); //(3000); Assert.AreEqual(total + 1, fin.LoadAll(true).Count()); fin.LoadAll(true).ToList().ForEach( x => { fin.Delete(x.Id); fin.DeleteForever(x.Id); }); Assert.AreEqual(0, fin.LoadAll(true).Count()); Task task = Task.Run( () => { for (int i = 0; i < total; i++) { Finance <object> ti = fin.Create(new Finance <object>()); } }); IEnumerable <Finance <object> > ttt = fin.LoadAll(true); TestHelperMethods.AssertAwait(1000); fin.Create(new Finance <object>()); // Assert.AreNotEqual(total + 1, fin.LoadAll(true).Count()); task.Wait(); //(3000); fin.LoadAll(true).ToList().ForEach( x => { fin.Delete(x.Id); fin.DeleteForever(x.Id); }); Assert.AreEqual(0, fin.LoadAll(true).Count()); StorageDatabase <History <object>, object> his = DatabaseService.Documents <History <object>, object>(); his.LoadAll(true).ToList().ForEach( x => { his.Delete(x.Id); his.DeleteForever(x.Id); }); }