Exemplo n.º 1
0
        public static void ASYNC_InsertThenUpdate_TypedRow(ICRUDDataStore store)
        {
            for (var i = 0; i < 10; i++)
            {
                store.InsertAsync(new Patient
                {
                    SSN        = i.ToString(),
                    First_Name = "Jack",
                    Last_Name  = "Kozloff_" + i,
                    DOB        = new DateTime(1980, 1, 12)
                }).Wait();
            }


            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.UpdateAsync(row).Wait();

            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"]);
        }
Exemplo n.º 2
0
        public static void ASYNC_InsertThenUpdate_TypedRow(ICRUDDataStore store)
        {
            for(var i=0; i<10; i++)
            {
                store.InsertAsync( new Patient
                               {
                                 SSN = i.ToString(),
                                 First_Name = "Jack",
                                 Last_Name = "Kozloff_"+i,
                                 DOB = new DateTime(1980, 1, 12)
                               }).Wait();
            }

            
            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.UpdateAsync( row ).Wait();

            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"]);
        }