public void WhereDynamicReference() { using (SoodaTransaction tran = new SoodaTransaction()) { AddReferenceField(tran); PKInt32 o = new PKInt32(); try { o.Parent = o; o[ReferenceField] = Contact.Mary; IEnumerable <PKInt32> pe = PKInt32.Linq().Where(p => ((Contact)p[ReferenceField]).LastSalary.Value == 42); CollectionAssert.IsEmpty(pe); pe = PKInt32.Linq().Where(p => ((Contact)p[ReferenceField]).LastSalary.Value == 123.123456789M); CollectionAssert.AreEquivalent(new PKInt32[] { o }, pe); pe = PKInt32.Linq().Where(p => ((Contact)p[ReferenceField]).GetLabel(false) == "Mary Manager"); CollectionAssert.AreEquivalent(new PKInt32[] { o }, pe); } finally { o.MarkForDelete(); Remove(ReferenceField, tran); } } }
public void IndexerSetDynamic() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); AddDateTimeField(tran); AddReferenceField(tran); try { PKInt32.GetRef(7777777)[IntField] = 42; PKInt32.GetRef(7777777)[DateTimeField] = new DateTime(2014, 10, 28); PKInt32.GetRef(7777777)[ReferenceField] = Contact.Ed; object value = PKInt32.GetRef(7777777)[IntField]; Assert.AreEqual(42, value); value = PKInt32.GetRef(7777777)[DateTimeField]; Assert.AreEqual(new DateTime(2014, 10, 28), value); value = PKInt32.GetRef(7777777)[ReferenceField]; Assert.AreEqual(Contact.Ed, value); } finally { Remove(ReferenceField, tran); Remove(DateTimeField, tran); Remove(IntField, tran); } } }
public void FieldUpdateTriggers() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); AddDateTimeField(tran); AddReferenceField(tran); try { PKInt32 o = PKInt32.GetRef(7777777); o[IntField] = 42; string expected = TriggerText(IntField, null, 42); o[DateTimeField] = new DateTime(2014, 10, 28); expected += TriggerText(DateTimeField, null, new DateTime(2014, 10, 28)); o[ReferenceField] = Contact.Ed; expected += TriggerText(ReferenceField, null, Contact.Ed); Assert.AreEqual(expected, o.triggersText); } finally { Remove(ReferenceField, tran); Remove(DateTimeField, tran); Remove(IntField, tran); } } }
public void IndexerGetDynamic() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); AddDateTimeField(tran); AddReferenceField(tran); try { object value = PKInt32.GetRef(7777777)[IntField]; Assert.IsNull(value); value = PKInt32.GetRef(7777777)[DateTimeField]; Assert.IsNull(value); value = PKInt32.GetRef(7777777)[ReferenceField]; Assert.IsNull(value); } finally { Remove(ReferenceField, tran); Remove(DateTimeField, tran); Remove(IntField, tran); } } }
public void Int32Test() { using (SoodaTransaction tran = new SoodaTransaction()) { PKInt32 test2 = PKInt32.Load(7777778); Assert.AreEqual(test2.Parent.Id, 7777777); Assert.AreEqual((string)test2.Parent.Data, "test data"); Assert.AreEqual((string)test2.Data, "test data 2"); } }
public void IndexerTypeCheckReference() { using (SoodaTransaction tran = new SoodaTransaction()) { AddReferenceField(tran); try { PKInt32.GetRef(7777777)[ReferenceField] = PKInt32.GetRef(7777777); } finally { Remove(ReferenceField, tran); } } }
public void IndexerTypeCheck() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); try { PKInt32.GetRef(7777777)[IntField] = "invalid"; } finally { Remove(IntField, tran); } } }
public void Int32Test() { string ser; using (SoodaTransaction tran = new SoodaTransaction()) { PKInt32 test = new PKInt32(); PKInt32 test2 = PKInt32.Load(7777777); Assert.AreEqual((string)test2.Data, "test data"); ser = tran.Serialize(); tran.Deserialize(ser); Assert.AreEqual(ser, tran.Serialize()); } }
public void SelectDynamic() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); try { PKInt32.GetRef(7777778)[IntField] = 42; IEnumerable <object> oe = PKInt32.Linq().Select(p => p[IntField]); CollectionAssert.AreEquivalent(new object[] { null, 42, null }, oe); } finally { Remove(IntField, tran); } } }
public void DynamicGetDynamic() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); try { dynamic d = PKInt32.GetRef(7777777); object value = d.IntDynamicField; Assert.IsNull(value); } finally { Remove(IntField, tran); } } }
public void NonNullString() { using (SoodaTransaction tran = new SoodaTransaction()) { AddStringField(tran); PKInt32 o = new PKInt32(); try { o.Parent = o; Assert.AreEqual("", o[StringField]); } finally { o.MarkForDelete(); Remove(StringField, tran); } } }
public void NonNullReference() { using (SoodaTransaction tran = new SoodaTransaction()) { AddReferenceField(tran); PKInt32 o = new PKInt32(); try { o.Parent = o; tran.Commit(); } finally { o.MarkForDelete(); Remove(ReferenceField, tran); } } }
public void WhereDynamicUpdate() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); try { PKInt32.GetRef(7777777)[IntField] = 42; IEnumerable <PKInt32> pe = PKInt32.Linq().Where(p => (int)p[IntField] == 5); CollectionAssert.IsEmpty(pe); pe = PKInt32.Linq().Where(p => (int)p[IntField] == 42); CollectionAssert.AreEquivalent(new PKInt32[] { PKInt32.GetRef(7777777) }, pe); } finally { Remove(IntField, tran); } } }
public void DontInsertNull() { using (SoodaTransaction tran = new SoodaTransaction()) { AddDateTimeField(tran); PKInt32 o = new PKInt32(); try { o.Parent = o; tran.SaveObjectChanges(); object count = ExecuteScalar(tran, "select count(*) from PKInt32 where id={0}", o.Id); Assert.AreEqual(1, count); count = ExecuteScalar(tran, "select count(*) from PKInt32_" + DateTimeField + " where id={0}", o.Id); Assert.AreEqual(0, count); } finally { o.MarkForDelete(); Remove(DateTimeField, tran); } } }
public void SoqlWrapperDynamicInsert() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); PKInt32 o = new PKInt32(); try { o.Parent = o; o[IntField] = 42; PKInt32List pl = PKInt32.GetList(new SoqlInt32WrapperExpression(new SoqlPathExpression(IntField)) == 5); CollectionAssert.IsEmpty(pl); pl = PKInt32.GetList(new SoqlInt32WrapperExpression(new SoqlPathExpression(IntField)) == 42); CollectionAssert.AreEquivalent(new PKInt32[] { o }, pl); } finally { o.MarkForDelete(); Remove(IntField, tran); } } }
public void SoqlDynamicInsert() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); PKInt32 o = new PKInt32(); try { o.Parent = o; o[IntField] = 42; PKInt32List pl = PKInt32.GetList(new SoqlBooleanRelationalExpression(new SoqlPathExpression(IntField), new SoqlLiteralExpression(5), SoqlRelationalOperator.Equal)); CollectionAssert.IsEmpty(pl); pl = PKInt32.GetList(new SoqlBooleanRelationalExpression(new SoqlPathExpression(IntField), new SoqlLiteralExpression(42), SoqlRelationalOperator.Equal)); CollectionAssert.AreEquivalent(new PKInt32[] { o }, pl); } finally { o.MarkForDelete(); Remove(IntField, tran); } } }
public void SoodaWhereClauseDynamicInsert() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); PKInt32 o = new PKInt32(); try { o.Parent = o; o[IntField] = 42; PKInt32List pl = PKInt32.GetList(new SoodaWhereClause("IntDynamicField = 5")); CollectionAssert.IsEmpty(pl); pl = PKInt32.GetList(new SoodaWhereClause("IntDynamicField = 42")); CollectionAssert.AreEquivalent(new PKInt32[] { o }, pl); } finally { o.MarkForDelete(); Remove(IntField, tran); } } }
public void WhereDynamicInsert() { using (SoodaTransaction tran = new SoodaTransaction()) { AddIntField(tran); PKInt32 o = new PKInt32(); try { o.Parent = o; o[IntField] = 42; IEnumerable <PKInt32> pe = PKInt32.Linq().Where(p => (int)p[IntField] == 5); CollectionAssert.IsEmpty(pe); pe = PKInt32.Linq().Where(p => (int)p[IntField] == 42); CollectionAssert.AreEquivalent(new PKInt32[] { o }, pe); } finally { o.MarkForDelete(); Remove(IntField, tran); } } }
static string TriggerText(string field, object oldVal, object newVal) { return(PKInt32.GetTriggerText("Before", field, oldVal, newVal) + PKInt32.GetTriggerText("After", field, oldVal, newVal)); }