public virtual void TestArray5() { NeoDatis.Odb.ODB odb = null; int size = 50; try { NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); System.Decimal[] array = new System.Decimal[size]; for (int i = 0; i < size; i++) { array[i] = new System.Decimal(((double)i) * 78954545 / 89); } ObjectWithNativeArrayOfBigDecimal owna = new ObjectWithNativeArrayOfBigDecimal("t1", array ); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <ObjectWithNativeArrayOfBigDecimal> l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal owna2 = l.GetFirst(); owna2.SetNumber(0, new System.Decimal(1)); odb.Store(owna2); odb.Close(); odb = Open("array1.neodatis"); l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal o = l.GetFirst(); AssertEquals(owna2.GetNumber(0), o.GetNumber(0)); AssertEquals(owna2.GetNumber(1), o.GetNumber(1)); if (isLocal) { // check that it was in place update and not normal update (by // creatig now object) AssertEquals(0, NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter. GetNbInPlaceUpdates()); AssertEquals(1, NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter. GetNbNormalUpdates()); } } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
public virtual void TestArrayUpdateDecreasingArraySize() { NeoDatis.Odb.ODB odb = null; int size = 50; try { DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); System.Decimal[] array = new System.Decimal[size]; System.Decimal[] array2 = new System.Decimal[size + 1]; for (int i = 0; i < size; i++) { array[i] = new System.Decimal(((double)i) * 78954545 / 89); array2[i] = new System.Decimal(((double)i) * 78954545 / 89); } array[size - 1] = new System.Decimal(99); array2[size] = new System.Decimal(100); ObjectWithNativeArrayOfBigDecimal owna = new ObjectWithNativeArrayOfBigDecimal("t1", array2 ); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <ObjectWithNativeArrayOfBigDecimal> l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal owna2 = l.GetFirst(); owna2.SetNumbers(array); odb.Store(owna2); odb.Close(); odb = Open("array1.neodatis"); l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal o = (ObjectWithNativeArrayOfBigDecimal )l.GetFirst(); AssertEquals(size, o.GetNumbers().Length); AssertEquals(new System.Decimal(99), o.GetNumber(size - 1)); AssertEquals(owna2.GetNumber(1), o.GetNumber(1)); odb = null; } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
public virtual void TestArray4() { NeoDatis.Odb.ODB odb = null; int size = 50; try { odb = Open("array1.neodatis"); System.Decimal[] array = new System.Decimal[size]; for (int i = 0; i < size; i++) { array[i] = new System.Decimal(((double)i) * 78954545 / 89); } ObjectWithNativeArrayOfBigDecimal owna = new ObjectWithNativeArrayOfBigDecimal("t1", array ); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <ObjectWithNativeArrayOfBigDecimal> l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal owna2 = l.GetFirst(); AssertEquals(owna.GetName(), owna2.GetName()); for (int i = 0; i < size; i++) { AssertEquals(owna.GetNumbers()[i], owna2.GetNumbers()[i]); } odb.Close(); odb = null; } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
/// <summary>Decreasing array size</summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestArrayUpdateDecreasingArraySize() { NeoDatis.Odb.ODB odb = null; int size = 50; try { DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); System.Decimal[] array = new System.Decimal[size]; System.Decimal[] array2 = new System.Decimal[size + 1]; for (int i = 0; i < size; i++) { array[i] = new System.Decimal(((double)i) * 78954545 / 89); array2[i] = new System.Decimal(((double)i) * 78954545 / 89); } array[size - 1] = new System.Decimal(99); array2[size] = new System.Decimal(100); ObjectWithNativeArrayOfBigDecimal owna = new ObjectWithNativeArrayOfBigDecimal("t1", array2 ); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects<ObjectWithNativeArrayOfBigDecimal> l = odb.GetObjects<ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal owna2 = l.GetFirst(); owna2.SetNumbers(array); odb.Store(owna2); odb.Close(); odb = Open("array1.neodatis"); l = odb.GetObjects<ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal o = (ObjectWithNativeArrayOfBigDecimal )l.GetFirst(); AssertEquals(size, o.GetNumbers().Length); AssertEquals(new System.Decimal(99), o.GetNumber(size - 1)); AssertEquals(owna2.GetNumber(1), o.GetNumber(1)); odb = null; } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
/// <summary> /// Test in place update for array when the number of elements remains the /// same /// </summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestArray5() { NeoDatis.Odb.ODB odb = null; int size = 50; try { NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); System.Decimal[] array = new System.Decimal[size]; for (int i = 0; i < size; i++) { array[i] = new System.Decimal(((double)i) * 78954545 / 89); } ObjectWithNativeArrayOfBigDecimal owna = new ObjectWithNativeArrayOfBigDecimal("t1", array ); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects<ObjectWithNativeArrayOfBigDecimal> l = odb.GetObjects<ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal owna2 = l.GetFirst(); owna2.SetNumber(0, new System.Decimal(1)); odb.Store(owna2); odb.Close(); odb = Open("array1.neodatis"); l = odb.GetObjects<ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal o = l.GetFirst(); AssertEquals(owna2.GetNumber(0), o.GetNumber(0)); AssertEquals(owna2.GetNumber(1), o.GetNumber(1)); if (isLocal) { // check that it was in place update and not normal update (by // creatig now object) AssertEquals(0, NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter. GetNbInPlaceUpdates()); AssertEquals(1, NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter. GetNbNormalUpdates()); } } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
/// <exception cref="System.Exception"></exception> public virtual void TestArray4() { NeoDatis.Odb.ODB odb = null; int size = 50; try { odb = Open("array1.neodatis"); System.Decimal[] array = new System.Decimal[size]; for (int i = 0; i < size; i++) { array[i] = new System.Decimal(((double)i) * 78954545 / 89); } ObjectWithNativeArrayOfBigDecimal owna = new ObjectWithNativeArrayOfBigDecimal("t1", array ); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects<ObjectWithNativeArrayOfBigDecimal> l = odb.GetObjects<ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal owna2 = l.GetFirst(); AssertEquals(owna.GetName(), owna2.GetName()); for (int i = 0; i < size; i++) { AssertEquals(owna.GetNumbers()[i], owna2.GetNumbers()[i]); } odb.Close(); odb = null; } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }