Пример #1
0
        public static void UpdateWithPredicate(ICRUDDataStore store)
        {
            var patient  = TestLogic.GetDefaultPatient();
            var affected = store.Insert(patient);

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

            persisted.Zip        = "010203";
            persisted.First_Name = "John";
            persisted.Last_Name  = "Smith";
            affected             = store.Update(persisted, null, (r, k, f) => f.Name != "First_Name" && f.Name != "Zip");
            Assert.AreEqual(1, affected);

            var updated = store.LoadRow(query);

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

            Assert.AreEqual(patient.First_Name, updated.First_Name);
            Assert.AreEqual(persisted.Last_Name, updated.Last_Name);
            Assert.AreEqual(patient.Zip, updated.Zip);
        }
Пример #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.LoadRow(new Query <Types>("CRUD.Types.Load", new GDID(0, 234)));

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

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

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

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

            Assert.AreEqual(145, row2.Age);

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

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

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

            Assert.IsNull(row3["Age"].AsNullableInt());
            Assert.IsNull(row3["DOB"].AsNullableDateTime());
            Assert.IsNull(row3["Bool_Bool"].AsNullableBool());
        }
Пример #3
0
        public static void InsertThenUpdate_TypedRow(ICRUDDataStore store)
        {
            for (var i = 0; i < 10; i++)
            {
                store.Insert(new Patient
                {
                    SSN        = i.ToString(),
                    First_Name = "Jack",
                    Last_Name  = "Kozloff_" + i,
                    DOB        = new DateTime(1980, 1, 12)
                });
            }


            var result = store.Load(new Query("CRUD.Patient.List", typeof(Patient))
            {
                new Query.Param("LN", "%loff_5")
            })[0];

            Assert.AreEqual(1, result.Count);
            var row = result[0] as Patient;

            Assert.AreEqual("5", row.SSN);

            row.Last_Name = "Gagarin";
            store.Update(row);

            result = store.Load(new Query("CRUD.Patient.List", typeof(Patient))
            {
                new Query.Param("LN", "%loff_5")
            })[0];
            Assert.AreEqual(0, result.Count);

            result = store.Load(new Query("CRUD.Patient.List", typeof(Patient))
            {
                new Query.Param("LN", "%garin")
            })[0];
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("5", result[0]["SSN"]);
            Assert.AreEqual("Gagarin", result[0]["Last_Name"]);
        }
Пример #4
0
        public static void InsertThenUpdate_TypedRow(ICRUDDataStore store)
        {
            for(var i=0; i<10; i++)
            {
                store.Insert( new Patient
                               {
                                 SSN = i.ToString(),
                                 First_Name = "Jack",
                                 Last_Name = "Kozloff_"+i,
                                 DOB = new DateTime(1980, 1, 12)
                               });
            }

            
            var result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_5") } )[0];
            
            Assert.AreEqual(1, result.Count);
            var row = result[0] as Patient;
            Assert.AreEqual("5", row.SSN);

            row.Last_Name = "Gagarin";
            store.Update( row );

            result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_5") } )[0];
            Assert.AreEqual(0, result.Count);

            result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%garin") } )[0];
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("5", result[0]["SSN"]);
            Assert.AreEqual("Gagarin", result[0]["Last_Name"]);
        }
Пример #5
0
        public static void UpdateWithPredicate(ICRUDDataStore store)
        {
            var patient = TestLogic.GetDefaultPatient();
            var affected = store.Insert(patient);
            Assert.AreEqual(1, affected);
            var query = new Query<Patient>("CRUD.Patient.List") { new Query.Param("LN", "%%") };
            var persisted = store.LoadRow(query);

            persisted.Zip = "010203";
            persisted.First_Name = "John";
            persisted.Last_Name = "Smith";
            affected = store.Update(persisted, null, (r, k, f) => f.Name != "First_Name" && f.Name != "Zip");
            Assert.AreEqual(1, affected);

            var updated = store.LoadRow(query);
            Assert.IsNotNull(updated);
            Assert.AreEqual(persisted.SSN, updated.SSN);
            Assert.AreEqual(persisted.City, updated.City);
            Assert.AreEqual(persisted.Address1, updated.Address1);
            Assert.AreEqual(persisted.Address2, updated.Address2);
            Assert.AreEqual(persisted.Amount, updated.Amount);
            Assert.AreEqual(persisted.Doctor_Phone, updated.Doctor_Phone);
            Assert.AreEqual(persisted.Phone, updated.Phone);
            Assert.AreEqual(persisted.DOB, updated.DOB);
            Assert.AreEqual(persisted.Note, updated.Note);

            Assert.AreEqual(patient.First_Name, updated.First_Name);
            Assert.AreEqual(persisted.Last_Name, updated.Last_Name);
            Assert.AreEqual(patient.Zip, updated.Zip);
        }
Пример #6
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.LoadRow(new Query<Types>("CRUD.Types.Load", new GDID(0, 234)));

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

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

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

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

            Assert.AreEqual(145, row2.Age);

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

            var row3 = store.LoadRow(new Query<Types>("CRUD.Types.Load", new GDID(0, 234)));
            Assert.IsFalse(row3.Age.HasValue);
            Assert.IsFalse(row3.Bool_Bool.HasValue);
            Assert.IsFalse(row3.DOB.HasValue);

            Assert.IsNull( row3["Age"].AsNullableInt());
            Assert.IsNull( row3["DOB"].AsNullableDateTime());
            Assert.IsNull( row3["Bool_Bool"].AsNullableBool());
        }