public void PopulateAndFindKey_TypedRows() { var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person))); for (var i = 0; i < 1000; i++) { tbl.Insert(new Person { ID = "POP{0}".Args(i), FirstName = "Oleg", LastName = "Popov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } Aver.AreEqual(1000, tbl.Count); var match1 = tbl.FindByKey("POP35"); Aver.IsNotNull(match1); Aver.AreObjectsEqual("Popov-35", match1["LastName"]); //example of dynamic row access var match2 = tbl.FindByKey("POP36") as Person; Aver.IsNotNull(match2); Aver.AreEqual("Popov-36", match2.LastName);//example of typed row access var match3 = tbl.FindByKey("DoesNotExist"); Aver.IsNull(match3); }
public void PopulateAndFindCompositeKey_TypedRows() { var tbl = new Rowset(Schema.GetForTypedDoc(typeof(WithCompositeKey))); for (var i = 0; i < 1000; i++) { tbl.Insert(new WithCompositeKey { ID = "ID{0}".Args(i), StartDate = new DateTime(1953, 12, 10), Description = "Descr{0}".Args(i) }); } Aver.AreEqual(1000, tbl.Count); var match1 = tbl.FindByKey("ID35", new DateTime(1953, 12, 10)); Aver.IsNotNull(match1); Aver.AreObjectsEqual("Descr35", match1["Description"]); var match2 = tbl.FindByKey("ID35", new DateTime(1953, 07, 10)); Aver.IsNull(match2); }
public void PopulateAndFindKey_DynamicRows() { var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person))); for (var i = 0; i < 1000; i++) { var row = new DynamicDoc(tbl.Schema); row["ID"] = "POP{0}".Args(i); row["FirstName"] = "Oleg"; row["LastName"] = "Popov-{0}".Args(i); row["DOB"] = new DateTime(1953, 12, 10); row["YearsInSpace"] = 12; tbl.Insert(row); } Aver.AreEqual(1000, tbl.Count); var match1 = tbl.FindByKey("POP35"); Aver.IsNotNull(match1); Aver.AreObjectsEqual("Popov-35", match1["LastName"]); var match2 = tbl.FindByKey("POP36") as DynamicDoc; Aver.IsNotNull(match2); Aver.AreObjectsEqual("Popov-36", match2["LastName"]); var match3 = tbl.FindByKey("DoesNotExist"); Aver.IsNull(match3); }
public void PopulateAndDeleteNonExisting() { var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person))); for (var i = 0; i < 1000; i++) { tbl.Insert(new Person { ID = "POP{0}".Args(i), FirstName = "Oleg", LastName = "Popov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } var delete = new Person { ID = "NONE17" }; var idx = tbl.Delete(delete); //<-------------!!!!!! Aver.IsTrue(idx == -1); Aver.AreEqual(1000, tbl.Count); var match = tbl.FindByKey("POP17") as Person; Aver.IsNotNull(match); }
public void PopulateAndUpsertExisting() { var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person))); for (var i = 0; i < 1000; i++) { tbl.Insert(new Person { ID = "POP{0}".Args(i), FirstName = "Oleg", LastName = "Popov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } var update = new Person { ID = "POP17", FirstName = "Yaroslav", LastName = "Suzkever", DOB = new DateTime(1952, 12, 10), YearsInSpace = 14 }; var res = tbl.Upsert(update);//<-------------!!!!!! Aver.IsTrue(res.Updated); var match = tbl.FindByKey("POP17") as Person; Aver.IsNotNull(match); Aver.AreEqual("Yaroslav", match.FirstName); Aver.AreEqual("Suzkever", match.LastName); }
public void BuildUsingAdHockSchema() { var schema = new Schema("TEZT", new Schema.FieldDef("ID", typeof(int), new List <FieldAttribute> { new FieldAttribute(required: true, key: true) }), new Schema.FieldDef("Description", typeof(string), new List <FieldAttribute> { new FieldAttribute(required: true) }) ); var tbl = new Rowset(schema); for (var i = 0; i < 1000; i++) { var row = new DynamicDoc(tbl.Schema); row["ID"] = i; row["Description"] = "Item-{0}".Args(i); tbl.Insert(row); } Aver.AreEqual(1000, tbl.Count); var match = tbl.FindByKey(178); Aver.IsNotNull(match); Aver.AreObjectsEqual("Item-178", match["Description"]); }
public void PopulateAndUpdateNonExisting() { var tbl = new Rowset(Schema.GetForTypedRow(typeof(Person))); for (var i = 0; i < 1000; i++) { tbl.Insert(new Person { ID = "POP{0}".Args(i), FirstName = "Oleg", LastName = "Popov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } var update = new Person { ID = "NONE17", FirstName = "Yaroslav", LastName = "Suzkever", DOB = new DateTime(1952, 12, 10), YearsInSpace = 14 }; var idx = tbl.Update(update);//<-------------!!!!!! Assert.IsTrue(idx == -1); var match = tbl.FindByKey("NONE17") as Person; Assert.IsNull(match); }
public void PopulateAndFindKey_MixedRows() { var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person))); for (var i = 0; i < 1000; i++) { var row = new DynamicDoc(tbl.Schema); row["ID"] = "DYN{0}".Args(i); row["FirstName"] = "Oleg"; row["LastName"] = "DynamicPopov-{0}".Args(i); row["DOB"] = new DateTime(1953, 12, 10); row["YearsInSpace"] = 12; tbl.Insert(row); tbl.Insert(new Person { ID = "TYPED{0}".Args(i), FirstName = "Oleg", LastName = "TypedPopov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } Aver.AreEqual(2000, tbl.Count); var match1 = tbl.FindByKey("DYN35"); Aver.IsNotNull(match1); Aver.IsTrue(match1 is DynamicDoc); Aver.AreObjectsEqual("DynamicPopov-35", match1["LastName"]); var match2 = tbl.FindByKey("TYPED36") as Person; Aver.IsNotNull(match2); Aver.AreObjectsEqual("TypedPopov-36", match2["LastName"]); var match3 = tbl.FindByKey("DoesNotExist"); Aver.IsNull(match3); }
public void PopulateAndUpsertNonExisting() { var tbl = new Rowset(Schema.GetForTypedRow(typeof(Person))); for (var i = 0; i < 1000; i++) { tbl.Insert(new Person { ID = "POP{0}".Args(i), FirstName = "Oleg", LastName = "Popov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } var update = new Person { ID = "GOODMAN17", FirstName = "John", LastName = "Jeffer", DOB = new DateTime(1952, 12, 10), YearsInSpace = 14 }; var existed = tbl.Upsert(update);//<-------------!!!!!! Assert.IsFalse(existed); Assert.AreEqual(1001, tbl.Count); var match = tbl.FindByKey("POP17") as Person; Assert.IsNotNull(match); Assert.AreEqual("Oleg", match.FirstName); Assert.AreEqual("Popov-17", match.LastName); match = tbl.FindByKey("GOODMAN17") as Person; Assert.IsNotNull(match); Assert.AreEqual("John", match.FirstName); Assert.AreEqual("Jeffer", match.LastName); }
public void PopulateAndDeleteExisting_UsingValues() { var tbl = new Rowset(Schema.GetForTypedRow(typeof(Person))); for (var i = 0; i < 1000; i++) { tbl.Insert(new Person { ID = "POP{0}".Args(i), FirstName = "Oleg", LastName = "Popov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } var idx = tbl.Delete("POP17"); //<-------------!!!!!! Assert.IsTrue(idx >= 0); Assert.AreEqual(999, tbl.Count); var match = tbl.FindByKey("POP17") as Person; Assert.IsNull(match); }