/// <exception cref="System.Exception"></exception> public virtual void Test() { IObjectContainer oc1 = OpenNewSession(); IObjectContainer oc2 = OpenNewSession(); IObjectContainer oc3 = OpenNewSession(); try { for (var i = 0; i < 1000; i++) { var obj1 = new SimpleObject("oc " + i, i); var obj2 = new SimpleObject("oc2 " + i, i); oc1.Store(obj1); oc2.Store(obj2); oc2.Rollback(); obj2 = new SimpleObject("oc2.2 " + i, i); oc2.Store(obj2); } oc1.Commit(); oc2.Rollback(); Assert.AreEqual(1000, oc1.Query(typeof (SimpleObject)).Count); Assert.AreEqual(1000, oc2.Query(typeof (SimpleObject)).Count); Assert.AreEqual(1000, oc3.Query(typeof (SimpleObject)).Count); } finally { oc1.Close(); oc2.Close(); oc3.Close(); } }
public virtual void _testDS() { IExtObjectContainer oc1 = OpenNewSession(); IExtObjectContainer oc2 = OpenNewSession(); IExtObjectContainer oc3 = OpenNewSession(); try { SimpleObject o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject ))); oc1.Delete(o1); SimpleObject o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject ))); Assert.AreEqual("hello", o2.GetS()); o2.SetS("o2"); oc2.Store(o2); oc1.Commit(); oc2.Commit(); o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject)) ); oc1.Refresh(o1, int.MaxValue); Assert.AreEqual("o2", o1.GetS()); o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject)) ); oc2.Refresh(o2, int.MaxValue); Assert.AreEqual("o2", o2.GetS()); SimpleObject o3 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc3, typeof(SimpleObject ))); oc1.Refresh(o1, int.MaxValue); Assert.AreEqual("o2", o3.GetS()); } finally { oc1.Close(); oc2.Close(); oc3.Close(); } }
public virtual void TestSRDC() { IExtObjectContainer oc1 = OpenNewSession(); IExtObjectContainer oc2 = OpenNewSession(); IExtObjectContainer oc3 = OpenNewSession(); try { SimpleObject o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject ))); oc1.Store(o1); SimpleObject o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject ))); Assert.AreEqual("hello", o2.GetS()); oc1.Rollback(); o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject)) ); oc2.Refresh(o2, int.MaxValue); Assert.AreEqual("hello", o2.GetS()); oc1.Commit(); o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject)) ); oc2.Refresh(o2, int.MaxValue); Assert.AreEqual("hello", o2.GetS()); oc1.Delete(o1); oc1.Commit(); AssertOccurrences(oc3, typeof(SimpleObject), 0); AssertOccurrences(oc2, typeof(SimpleObject), 0); } finally { oc1.Close(); oc2.Close(); oc3.Close(); } }