Пример #1
0
        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);
                }
            }
        }
Пример #2
0
 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);
         }
     }
 }
Пример #3
0
 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);
         }
     }
 }
Пример #4
0
        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);
                }
            }
        }
Пример #5
0
        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");
            }
        }
Пример #6
0
 public void IndexerTypeCheckReference()
 {
     using (SoodaTransaction tran = new SoodaTransaction())
     {
         AddReferenceField(tran);
         try
         {
             PKInt32.GetRef(7777777)[ReferenceField] = PKInt32.GetRef(7777777);
         }
         finally
         {
             Remove(ReferenceField, tran);
         }
     }
 }
Пример #7
0
 public void IndexerTypeCheck()
 {
     using (SoodaTransaction tran = new SoodaTransaction())
     {
         AddIntField(tran);
         try
         {
             PKInt32.GetRef(7777777)[IntField] = "invalid";
         }
         finally
         {
             Remove(IntField, tran);
         }
     }
 }
Пример #8
0
        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());
            }
        }
Пример #9
0
 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);
         }
     }
 }
Пример #10
0
 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);
         }
     }
 }
Пример #11
0
 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);
         }
     }
 }
Пример #12
0
 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);
         }
     }
 }
Пример #13
0
        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);
                }
            }
        }
Пример #14
0
 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);
         }
     }
 }
Пример #15
0
        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);
                }
            }
        }
Пример #16
0
        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);
                }
            }
        }
Пример #17
0
        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);
                }
            }
        }
Пример #18
0
        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);
                }
            }
        }
Пример #19
0
 static string TriggerText(string field, object oldVal, object newVal)
 {
     return(PKInt32.GetTriggerText("Before", field, oldVal, newVal)
            + PKInt32.GetTriggerText("After", field, oldVal, newVal));
 }