Example #1
0
        public static void QueryInsertQuery(ICRUDDataStore store)
        {
            var query = new Query("CRUD.Patient.List") { new Query.Param("LN", "%loff") };
            var result = store.Load( query );  

            Assert.AreEqual(1, result.Count);
            var rowset = result[0];
            Assert.AreEqual(0, rowset.Count);
                
            var row = new DynamicRow(rowset.Schema);

            row["ssn"] = "999-88-9012";
            row["First_Name"] = "Jack";
            row["Last_Name"] = "Kozloff";
            row["DOB"] = new DateTime(1980, 1, 12);

            Assert.IsNull( row.Validate());

            store.Insert(row);   

                      
            result = store.Load( query );  

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

            Assert.AreEqual(1, rowset.Count);
            Assert.AreEqual("Jack", rowset[0]["First_Name"]);
            
        }
Example #2
0
        public static void InsertThenDelete_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);

            store.Delete(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", "%loff_%")
            })[0];
            Assert.AreEqual(9, result.Count);
        }
Example #3
0
        public static void ExecuteCustomCommandHandler(ICRUDDataStore store)
        {
            var query = new Query("CustomTestCommandHandler")
            {
                new Query.Param("Msg", "we are on the moon!")
            };
            var result = store.Load(query);

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

            Aver.AreEqual(2, rowset.Count);

            Aver.AreEqual("Jack", rowset[0]["First_Name"].AsString());
            Aver.AreEqual("Mary", rowset[1]["First_Name"].AsString());
            Aver.AreEqual("we are on the moon!", rowset[1]["Address1"].AsString());
        }
Example #4
0
        public static void InsertThenUpsert_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);
            Assert.AreEqual(null, row.Phone);

            row.Phone = "22-94-92";
            store.Upsert(row);

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

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

            row = new Patient
            {
                SSN        = "-100",
                First_Name = "Vlad",
                Last_Name  = "Lenin",
                DOB        = new DateTime(1871, 4, 20)
            };

            store.Upsert(row);

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

            result = store.Load(new Query("CRUD.Patient.List", typeof(Patient))
            {
                new Query.Param("LN", "Lenin")
            })[0];
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("Vlad", result[0]["First_Name"]);
        }
Example #5
0
        public static void QueryInsertQuery_TypedRow(ICRUDDataStore store)
        {
            var query = new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff") };
            var result = store.Load( query );  

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

            row.SSN = "999-88-9012";
            row.First_Name = "Jack";
            row.Last_Name = "Kozloff";
            row.DOB = new DateTime(1980, 1, 12);

            Assert.IsNull( row.Validate());

            store.Insert(row);   

                      
            result = store.Load( query );  

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

            Assert.AreEqual(1, rowset.Count);
            Assert.IsInstanceOf<Patient>( rowset[0] );
            Assert.AreEqual("Jack", rowset[0]["First_Name"]);
            
        }
Example #6
0
        public static void ASYNC_InsertThenUpsert_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);
            Assert.AreEqual(null, row.Phone);

            row.Phone = "22-94-92";
            store.UpsertAsync( row ).Wait();
            
            result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_5") } )[0];
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("22-94-92", result[0]["Phone"]);

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

            row = new Patient
                               {
                                 SSN = "-100",
                                 First_Name = "Vlad",
                                 Last_Name = "Lenin",
                                 DOB = new DateTime(1871, 4, 20)
                               };

            store.UpsertAsync(row).Wait();

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

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

        }
Example #7
0
        public static void ASYNC_InsertThenDelete_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);

            store.DeleteAsync( 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", "%loff_%") } )[0];
            Assert.AreEqual(9, result.Count);

        }
Example #8
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"]);
        }
Example #9
0
        public static void InsertInTransaction_Rollback_TypedRow(ICRUDDataStore store)
        {
            var transaction = store.BeginTransaction();

            for(var i=0; i<25; i++)
            {
                transaction.Insert( new Patient
                               {
                                 SSN = "999-88-9012",
                                 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%") } )[0];
            
            Assert.AreEqual(0, result.Count);

            transaction.Rollback();

            result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff%") } )[0];
            
            Assert.AreEqual(0, result.Count);
        }
Example #10
0
        public static void InsertManyUsingLogChanges_TypedRow(ICRUDDataStore store)
        {
            var rowset = new Rowset( Schema.GetForTypedRow(typeof(Patient)));
            rowset.LogChanges = true;
       
            for(var i=0; i<1000; i++)
            {
                rowset.Insert( new Patient
                               {
                                 SSN = "999-88-9012",
                                 First_Name = "Jack",
                                 Last_Name = "Kozloff"+i,
                                 DOB = new DateTime(1980, 1, 12)
                               });
            }
            
            for(var i=0; i<327; i++)
            {
                rowset.Insert( new Patient 
                               {
                                 SSN = "999-88-9012",
                                 First_Name = "Jack",
                                 Last_Name = "Abramovich"+i,
                                 DOB = new DateTime(2001, 1, 12)
                               });
            }

            store.Save( rowset );

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

            result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%ovich%") } )[0];
            
            Assert.AreEqual(327, result.Count);
        }
Example #11
0
        public static void QueryInsertQuery_DynamicRow(ICRUDDataStore store)
        {
            var query = new Query<DynamicRow>("CRUD.Patient.List") { new Query.Param("LN", "%ruman") };
            var result = store.Load( query );  

            Assert.AreEqual(1, result.Count);
            var rowset = result[0];
            Assert.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);

            Assert.IsNull( row.Validate());

            store.Insert(row);   

                      
            var row2 = store.LoadRow( query );  

            Assert.IsNotNull(row2);
            Assert.IsInstanceOf<DynamicRow>( row2 );
            Assert.AreEqual("Mans", row2["First_Name"]);
            
        }