public void CompositeUserTypeNested() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Citizen), typeof(NestedCitizen)); Recreate(); String fileName = null; try { fileName = Path.GetTempFileName(); ActiveRecordStarter.GenerateCreationScripts(fileName); using (TextReader r = new StreamReader(fileName)) { string schema = r.ReadToEnd(); Assert.IsTrue(Regex.IsMatch(schema, @"\bfirstname\b", RegexOptions.IgnoreCase)); Assert.IsTrue(Regex.IsMatch(schema, @"\blastname\b", RegexOptions.IgnoreCase)); Assert.IsTrue(Regex.IsMatch(schema, @"\bmanufacturer_firstname\b", RegexOptions.IgnoreCase)); Assert.IsTrue(Regex.IsMatch(schema, @"\bmanufacturer_lastname\b", RegexOptions.IgnoreCase)); } } finally { if (fileName != null) { File.Delete(fileName); } } NestedCitizen c = new NestedCitizen(); c.Name.Name = new string[] { "Jonh", "Doe" }; c.ManufacturerName.Name = new string[] { "Acme", "Inc" }; c.Create(); NestedCitizen loaded = NestedCitizen.Find(c.Id); Assert.IsNotNull(loaded); Assert.AreEqual("Jonh", loaded.Name.Name[0]); Assert.AreEqual("Doe", loaded.Name.Name[1]); Assert.AreEqual("Acme", loaded.ManufacturerName.Name[0]); Assert.AreEqual("Inc", loaded.ManufacturerName.Name[1]); }
public void CompositeUserTypeNested() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Citizen), typeof(NestedCitizen)); Recreate(); String fileName = null; try { fileName = Path.GetTempFileName(); ActiveRecordStarter.GenerateCreationScripts(fileName); using (TextReader r = new StreamReader(fileName)) { string schema = r.ReadToEnd(); Assert.IsTrue(Regex.IsMatch(schema, @"\bfirstname\b", RegexOptions.IgnoreCase)); Assert.IsTrue(Regex.IsMatch(schema, @"\blastname\b", RegexOptions.IgnoreCase)); Assert.IsTrue(Regex.IsMatch(schema, @"\bmanufacturer_firstname\b", RegexOptions.IgnoreCase)); Assert.IsTrue(Regex.IsMatch(schema, @"\bmanufacturer_lastname\b", RegexOptions.IgnoreCase)); } } finally { if (fileName != null) File.Delete(fileName); } NestedCitizen c = new NestedCitizen(); c.Name.Name = new string[] { "Jonh", "Doe" }; c.ManufacturerName.Name = new string[] { "Acme", "Inc" }; c.Create(); NestedCitizen loaded = NestedCitizen.Find(c.Id); Assert.IsNotNull(loaded); Assert.AreEqual("Jonh", loaded.Name.Name[0]); Assert.AreEqual("Doe", loaded.Name.Name[1]); Assert.AreEqual("Acme", loaded.ManufacturerName.Name[0]); Assert.AreEqual("Inc", loaded.ManufacturerName.Name[1]); }