public virtual void Test7() { var baseName = GetBaseName(); IOdb odb = null; odb = Open(baseName); var f1 = new VO.Login.Function("function1"); var f2 = new VO.Login.Function("function2"); var f3 = new VO.Login.Function("function3"); odb.Store(f1); odb.Store(f2); odb.Store(f3); var id = odb.GetObjectId(f3); odb.Close(); try { odb = Open(baseName); var f3bis = (VO.Login.Function)odb.GetObjectFromId(id); odb.Delete(f3bis); odb.Close(); odb = Open(baseName); var query = odb.Query <VO.Login.Function>(); var l = query.Execute <VO.Login.Function>(); odb.Close(); AssertEquals(2, l.Count); } catch (OdbRuntimeException) { odb.Close(); DeleteBase(baseName); } }
public virtual void Test9() { var baseName = GetBaseName(); IOdb odb = null; odb = Open(baseName); var f1 = new VO.Login.Function("function1"); var f2 = new VO.Login.Function("function2"); var f3 = new VO.Login.Function("function3"); odb.Store(f1); odb.Store(f2); odb.Store(f3); var id = odb.GetObjectId(f3); odb.Close(); odb = Open(baseName); var f3bis = (VO.Login.Function)odb.GetObjectFromId(id); odb.Delete(f3bis); odb.Close(); odb = Open(baseName); odb.Store(new VO.Login.Function("last function")); odb.Close(); odb = Open(baseName); var query = odb.Query <VO.Login.Function>(); var l = query.Execute <VO.Login.Function>(); odb.Close(); AssertEquals(3, l.Count); }
public virtual void Test20() { var baseName = GetBaseName(); IOdb odb = null; odb = Open(baseName); var f0 = new VO.Login.Function("1function0"); odb.Store(f0); odb.Close(); odb = Open(baseName); var f1 = new VO.Login.Function("function1"); odb.Store(f1); odb.Commit(); var query = odb.Query <VO.Login.Function>(); query.Descend("name").Constrain("func%").Like(); var objects = query.Execute <VO.Login.Function>(); AssertEquals(1, objects.Count); var f2 = objects.GetFirst(); var oid = odb.GetObjectId(f2); odb.DeleteObjectWithId(oid); var query1 = odb.Query <VO.Login.Function>(); AssertEquals(1, query1.Execute <VO.Login.Function>().Count); odb.Close(); odb = Open(baseName); var query2 = odb.Query <VO.Login.Function>(); objects = query2.Execute <VO.Login.Function>(); AssertEquals(1, objects.Count); }
public virtual void Test19() { var baseName = GetBaseName(); IOdb odb = null; odb = Open(baseName); var f1 = new VO.Login.Function("function1"); odb.Store(f1); odb.Close(); odb = Open(baseName); var query = odb.Query <VO.Login.Function>(); var objects = query.Execute <VO.Login.Function>(); AssertEquals(1, objects.Count); var f2 = objects.GetFirst(); var oid = odb.GetObjectId(f2); odb.DeleteObjectWithId(oid); var query1 = odb.Query <VO.Login.Function>(); AssertEquals(0, query1.Execute <VO.Login.Function>().Count); odb.Close(); odb = Open(baseName); var query2 = odb.Query <VO.Login.Function>(); objects = query2.Execute <VO.Login.Function>(); AssertEquals(0, objects.Count); }
public virtual void Test13() { var baseName = GetBaseName(); IOdb odb = null; DeleteBase(baseName); odb = Open(baseName); var f1 = new VO.Login.Function("function1"); var f2 = new VO.Login.Function("function2"); var f3 = new VO.Login.Function("function3"); odb.Store(f1); odb.Store(f2); odb.Store(f3); var idf1 = odb.GetObjectId(f1); var idf2 = odb.GetObjectId(f2); var idf3 = odb.GetObjectId(f3); var storageEngine = ((global::NDatabase.Odb)odb).GetStorageEngine(); var p1 = storageEngine.GetObjectReader().GetObjectPositionFromItsOid(idf1, true, false); var p2 = storageEngine.GetObjectReader().GetObjectPositionFromItsOid(idf2, true, false); var p3 = storageEngine.GetObjectReader().GetObjectPositionFromItsOid(idf3, true, false); odb.Close(); try { odb = Open(baseName); f1 = (VO.Login.Function)odb.GetObjectFromId(idf1); f2 = (VO.Login.Function)odb.GetObjectFromId(idf2); f3 = (VO.Login.Function)odb.GetObjectFromId(idf3); odb.Delete(f3); odb.Delete(f2); odb.Close(); odb = Open(baseName); var query = odb.Query <VO.Login.Function>(); var l = query.Execute <VO.Login.Function>(); odb.Close(); AssertEquals(1, l.Count); } catch (OdbRuntimeException) { DeleteBase(baseName); throw; } DeleteBase(baseName); }
public virtual void Test5_byOid() { IOdb odb = null; var baseName = GetBaseName(); odb = Open(baseName); var f = new VO.Login.Function("function1"); odb.Store(f); var oid = odb.GetObjectId(f); try { odb.DeleteObjectWithId(oid); var id2 = odb.GetObjectId(f); Fail("The object has been deleted, the id should have been marked as deleted"); } catch (OdbRuntimeException) { odb.Close(); DeleteBase(baseName); } }
public virtual void Test12() { var baseName = GetBaseName(); IOdb odb = null; odb = Open(baseName); var f1 = new VO.Login.Function("function1"); var f2 = new VO.Login.Function("function2"); var f3 = new VO.Login.Function("function3"); odb.Store(f1); odb.Store(f2); odb.Store(f3); var idf1 = odb.GetObjectId(f1); var idf2 = odb.GetObjectId(f2); var idf3 = odb.GetObjectId(f3); odb.Close(); try { odb = Open(baseName); odb.DeleteObjectWithId(idf3); odb.DeleteObjectWithId(idf2); odb.Close(); odb = Open(baseName); var query = odb.Query <VO.Login.Function>(); var l = query.Execute <VO.Login.Function>(); odb.Close(); AssertEquals(1, l.Count); } catch (OdbRuntimeException) { DeleteBase(baseName); throw; } }