예제 #1
0
        public void CanQueryByUlongProperty()
        {
            Database db = new SQLiteDatabase(nameof(SaveAndQueryTest));

            db.TryEnsureSchema <DaoReferenceObject>();
            DaoReferenceObject.LoadAll(db).Delete(db);
            ulong testValue = 8374384738473847;

            DaoReferenceObject referenceObject = new DaoReferenceObject()
            {
                IntProperty       = 10,
                DecimalProperty   = 10,
                LongProperty      = 10,
                ULongProperty     = testValue,
                DateTimeProperty  = Instant.Now,
                BoolProperty      = true,
                ByteArrayProperty = "This is the byte array property".ToBytes(),
                StringProperty    = "This is the string property"
            };

            referenceObject.Id.ShouldBeNull("Id should have been null");
            referenceObject.Save(db);
            string referenceJson = referenceObject.ToJsonSafe().ToJson();

            referenceObject.Id.ShouldNotBeNull("Id should not have been null");

            DaoReferenceObject[] retrieved = DaoReferenceObject.Where(c => c.ULongProperty == testValue, db).ToArray();
            Expect.AreEqual(1, retrieved.Length);
            DaoReferenceObject instance = retrieved[0];

            Expect.AreEqual(instance.ULongProperty, referenceObject.ULongProperty);
            Expect.AreEqual(referenceObject, instance);
            Expect.AreEqual(referenceJson, instance.ToJsonSafe().ToJson());
            Expect.AreEqual(testValue, instance.ULongProperty);

            Message.PrintLine(db.ConnectionString);
        }