public void Setup() { //Create the test data. DBObject db = new DBObject(Utility.connMy, "users", "external_id"); //Lie about the primary key so we can insert it. DBRow dan = new DBRow(); dan["id"] = 2; dan["first_name"] = "Dan"; dan["middle_initial"] = "A"; dan["last_name"] = "Rese"; dan["email"] = "*****@*****.**"; dan.Insert(db); DBRow chris = new DBRow(); chris["id"] = 1313; chris["first_name"] = "Chris"; chris["middle_initial"] = "A"; chris["last_name"] = "Richards"; chris["email"] = "*****@*****.**"; chris.Insert(db); DBRow ross = new DBRow(); ross["id"] = 1315; ross["first_name"] = "Ross"; ross["middle_initial"] = "A"; ross["last_name"] = "Weaver"; ross["email"] = "*****@*****.**"; ross.Insert(db); DBRow rick = new DBRow(); rick["id"] = 1327; rick["first_name"] = "Rick"; rick["middle_initial"] = "R"; rick["last_name"] = "Frazer"; rick["email"] = "*****@*****.**"; rick.Insert(db); }
public void InsertRecordShowInRow() { //Inserting a Record, the record should be added to the objects Rows property //-- // These parrts are tested by InsertRecord() //Verify our record doesn't already exist. DBObject obj = new DBObject(Utility.connMy, "users", "id"); obj.Where("email=@0", "*****@*****.**"); Assert.AreEqual(0, obj.Rows.Count); //Create a new Row DBRow ladygaga = new DBRow(); ladygaga["first_name"] = "Lady"; ladygaga["last_name"] = "Gaga"; ladygaga["email"] = "*****@*****.**"; //-- Assert.AreEqual(0, obj.Rows.Count); //Insert the Row ladygaga.Insert(obj); //Test that it's in the DBObject Assert.AreEqual(1, obj.Rows.Count); //-- // These parrts are tested by InsertRecord() //Try to get it now obj.Where("email=@0", "*****@*****.**"); Assert.AreEqual(1, obj.Rows.Count, "Checking that the record exists."); //Now get rid of it. obj.Rows[0].Delete(obj); //Verify that it's gone obj.Where("email=@0", "*****@*****.**"); Assert.AreEqual(0, obj.Rows.Count); //-- }
public void InsertRecord() { //Make sure the row doesn't exist already. DBObject obj = new DBObject(Utility.connMy, "users", "id"); obj.Where("email=@0", "*****@*****.**"); Assert.AreEqual(0, obj.Rows.Count); //Create a new Row DBRow ladygaga = new DBRow(); ladygaga["first_name"] = "Lady"; ladygaga["last_name"] = "Gaga"; ladygaga["email"] = "*****@*****.**"; //Insert the Row ladygaga.Insert(obj); //Try to get it now obj.Where("email=@0", "*****@*****.**"); Assert.AreEqual(1, obj.Rows.Count, "Checking that the record exists."); //Now get rid of it. obj.Rows[0].Delete(obj); //Verify that it's gone obj.Where("email=@0", "*****@*****.**"); Assert.AreEqual(0, obj.Rows.Count); }