Esempio n. 1
0
        public static void UpsertWithPredicate(ICrudDataStore store)
        {
            var patient  = TestLogic.GetDefaultPatient();
            var affected = store.Insert(patient);

            Aver.AreEqual(1, affected);
            var query = new Query <Patient>("CRUD.Queries.Patient.List")
            {
                new Query.Param("LN", "%%")
            };
            var persisted = store.LoadDoc(query);

            persisted.Zip        = "010203";
            persisted.First_Name = "John";
            persisted.Last_Name  = "Smith";
            affected             = store.Upsert(persisted, (r, k, f) => f.Name != "Zip");
            Aver.AreEqual(2, affected);

            var updated = store.LoadDoc(query);

            Aver.IsNotNull(updated);
            Aver.AreEqual(persisted.SSN, updated.SSN.Trim());
            Aver.AreEqual(persisted.City, updated.City);
            Aver.AreEqual(persisted.Address1, updated.Address1);
            Aver.AreEqual(persisted.Address2, updated.Address2);
            Aver.AreEqual(persisted.Amount, updated.Amount);
            Aver.AreEqual(persisted.Doctor_Phone, updated.Doctor_Phone);
            Aver.AreEqual(persisted.Phone, updated.Phone.Trim());
            Aver.AreEqual(persisted.DOB, updated.DOB);
            Aver.AreEqual(persisted.Note, updated.Note);

            Aver.AreEqual(persisted.First_Name, updated.First_Name);
            Aver.AreEqual(persisted.Last_Name, updated.Last_Name);
            Aver.AreEqual(patient.Zip, updated.Zip); // notice ZIP remains the same
        }
Esempio n. 2
0
        public static void TypedRowTestVariousTypes(ICrudDataStore store)
        {
            var row = new Types();

            row.GDID        = new GDID(0, 234);
            row.Screen_Name = "User1";
            row.String_Name = "Some user 1";
            row.Char_Name   = "Some user 2";
            row.Bool_Char   = true; //notice TRUE for both char and bool columns below
            row.Bool_Bool   = true;

            row["AMOUNT"] = 145670.23m;

            row["DOB"] = new DateTime(1980, 12, 1);
            row["Age"] = 145;

            store.Insert(row);

            var row2 = store.LoadDoc(new Query <Types>("CRUD.Queries.Types.Load", new GDID(0, 234)));

            Aver.IsNotNull(row2);
            Aver.AreEqual(new GDID(0, 0, 234), row2.GDID);
            Aver.AreEqual("User1", row2.Screen_Name);
            Aver.AreEqual("Some user 1", row2.String_Name);
            Aver.AreEqual("Some user 2", row2.Char_Name);

            Aver.AreEqual(true, row2.Bool_Char.Value);
            Aver.AreEqual(true, row2.Bool_Bool.Value);

            Aver.AreEqual(145670.23m, row2.Amount);

            Aver.AreEqual(1980, row2.DOB.Value.Year);

            Aver.AreEqual(145, row2.Age);

            row.Age       = null;
            row.Bool_Bool = null;
            row.DOB       = null;
            store.Update(row);

            var row3 = store.LoadDoc(new Query <Types>("CRUD.Queries.Types.Load", new GDID(0, 234)));

            Aver.IsFalse(row3.Age.HasValue);
            Aver.IsFalse(row3.Bool_Bool.HasValue);
            Aver.IsFalse(row3.DOB.HasValue);

            Aver.IsNull(row3["Age"].AsNullableInt());
            Aver.IsNull(row3["DOB"].AsNullableDateTime());
            Aver.IsNull(row3["Bool_Bool"].AsNullableBool());
        }
Esempio n. 3
0
        public static void InsertWithPredicate(ICrudDataStore store)
        {
            var patient  = TestLogic.GetDefaultPatient();
            var affected = store.Insert(patient, (r, k, f) => f.Name != "State" && f.Name != "Zip");

            Aver.AreEqual(1, affected);

            var query = new Query <Patient>("CRUD.Queries.Patient.List")
            {
                new Query.Param("LN", "%%")
            };
            var persisted = store.LoadDoc(query);

            Aver.IsNotNull(persisted);
            Aver.AreEqual(patient.First_Name, persisted.First_Name);
            Aver.AreEqual(patient.Last_Name, persisted.Last_Name);
            Aver.AreEqual(patient.SSN, persisted.SSN.Trim());
            Aver.AreEqual(patient.City, persisted.City);
            Aver.AreEqual(patient.Address1, persisted.Address1);
            Aver.AreEqual(patient.Address2, persisted.Address2);
            Aver.AreEqual(patient.Amount, persisted.Amount);
            Aver.AreEqual(patient.Doctor_Phone, persisted.Doctor_Phone);
            Aver.AreEqual(patient.Phone, persisted.Phone.Trim());
            Aver.AreEqual(patient.DOB, persisted.DOB);
            Aver.AreEqual(patient.Note, persisted.Note);

            Aver.IsNull(persisted.State);
            Aver.IsNull(persisted.Zip);
        }
Esempio n. 4
0
        public static void QueryInsertQuery_DynamicRow(ICrudDataStore store)
        {
            var query = new Query <DynamicDoc>("CRUD.Queries.Patient.List")
            {
                new Query.Param("LN", "%ruman")
            };
            var result = store.Load(query);

            Aver.AreEqual(1, result.Count);
            var rowset = result[0];

            Aver.AreEqual(0, rowset.Count);

            var row = new Patient();

            row.SSN        = "999-88-9012";
            row.First_Name = "Mans";
            row.Last_Name  = "Skolopendruman";
            row.DOB        = new DateTime(1970, 1, 12);

            Aver.IsNull(row.Validate());

            store.Insert(row);


            var row2 = store.LoadDoc(query);

            Aver.IsNotNull(row2);
            Aver.IsTrue(row2 is DynamicDoc);
            Aver.AreObjectsEqual("Mans", row2["First_Name"]);
        }