protected bool IsIdentity(Hashtable fieldInfo) { bool flag = false; StringTheory theory = new StringTheory("SELECT COLUMNPROPERTY( OBJECT_ID('%TABLE_NAME%'),'%COLUMN_NAME%','IsIdentity') AS IS_IDENTITY"); theory.Populate(fieldInfo, "%*%"); ArrayList results = new ArrayList(); this.process(theory.ToString(), results); if (results.Count > 0) { flag = ((Hashtable)results[0])["IS_IDENTITY"].ToString() == "1"; } return(flag); }
public void DEFERRED_testAsteriskBasedCustomTemplatePopulationWithHashtable() { string str = "Name: George BushAddress: 1600 Pennsylvania Ave. (c/o Laura), Washington, DC 20500Phone: 202-456-1414Age: 57"; StringTheory theory = new StringTheory("Name: ***FirstName*** ***LastName***Address: ***Address1*** ***Address2***, ***City***, ***State*** ***Zip***Phone: ***Phone***Age: ***Age***"); Hashtable values = new Hashtable(); values["FirstName"] = "George"; values["LastName"] = "Bush"; values["Address1"] = "1600 Pennsylvania Ave."; values["Address2"] = "(c/o Laura)"; values["City"] = "Washington"; values["State"] = "DC"; values["Zip"] = "20500"; values["Phone"] = "202-456-1414"; values["Age"] = 0x39; theory.Populate(values, @"\*\*\**\*\*\*"); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string."); }
public string DescribeStream(string stream) { StringTheory theory = new StringTheory("<stream name=\"%stream%\">\n%fields%</stream>\n"); StringTheory theory2 = new StringTheory(); ArrayList list = new ArrayList(); this.ListColumns(stream, list); theory.Replace("%stream%", stream); foreach (Hashtable hashtable in list) { theory2.Append("<field name=\"%COLUMN_NAME%\" type=\"%DATA_TYPE%\" identity=\"%IDENTITY%\"/>\n"); theory2.Populate(hashtable, "%*%"); theory2.Replace("%IDENTITY%", this.IsIdentity(hashtable)); } theory.Replace("%fields%", theory2); return(theory.ToString()); }
public void testCustomTemplatePopulationWithResultSetEntry() { OleDbConnection connected = this.GetConnected(); this.PopulatingRecordCreate(connected); string str = "Name: George BushPhone: 202-456-1414"; StringTheory theory = new StringTheory("Name: $FIRST_NAME $LAST_NAMEPhone: $PHONE"); OleDbDataReader reader = this.PopulatingRecordRetrieve(connected); if (!reader.IsClosed && reader.HasRows) { reader.Read(); theory.Populate((IDataReader)reader, "$*"); } reader.Close(); this.PopulatingRecordCleanup(connected); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string." + theory); connected.Close(); }
public void testCustomTemplatePopulationWithHashtable() { string str = "Name: George BushAddress: 1600 Pennsylvania Ave. (c/o Laura), Washington, DC 20500Phone: 202-456-1414Age: 57"; StringTheory theory = new StringTheory("Name: $FirstName $LastNameAddress: $Address1 $Address2, $City, $State $ZipPhone: $PhoneAge: $Age"); Hashtable values = new Hashtable(); values["FirstName"] = "George"; values["LastName"] = "Bush"; values["Address1"] = "1600 Pennsylvania Ave."; values["Address2"] = "(c/o Laura)"; values["City"] = "Washington"; values["State"] = "DC"; values["Zip"] = "20500"; values["Phone"] = "202-456-1414"; values["Age"] = 0x39; theory.Populate(values, "$*"); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string."); }
public void testCustomTemplatePopulationWithBean() { string str = "Name: George BushAddress: 1600 Pennsylvania Ave. (c/o Laura), Washington, DC 20500Phone: 202-456-1414Age: 57"; StringTheory theory = new StringTheory("Name: $FirstName $LastNameAddress: $Address1 $Address2, $City, $State $ZipPhone: $PhoneAge: $Age"); theory.Populate(this.CreatePersonBean(), "$*"); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string."); }
public void testTemplatePopulationWithResultSetEntry() { OleDbConnection connected = this.GetConnected(); this.PopulatingRecordCreate(connected); string str = "Name: George BushPhone: 202-456-1414"; StringTheory theory = new StringTheory("Name: %FIRST_NAME% %LAST_NAME%Phone: %PHONE%"); OleDbDataReader anObject = this.PopulatingRecordRetrieve(connected); Assert.NotNull(anObject, "The result set is coming back null."); if (!anObject.IsClosed && anObject.HasRows) { anObject.Read(); theory.Populate((IDataReader)anObject, "%*%"); } anObject.Close(); this.PopulatingRecordCleanup(connected); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string. " + theory); anObject.Close(); connected.Close(); }
public void testTemplatePopulationWithHashtable() { string str = "Name: George BushAddress: 1600 Pennsylvania Ave. (c/o Laura), Washington, DC 20500Phone: 202-456-1414Age: 57"; StringTheory theory = new StringTheory("Name: %FirstName% %LastName%Address: %Address1% %Address2%, %City%, %State% %Zip%Phone: %Phone%Age: %Age%"); Hashtable values = new Hashtable(); values["FirstName"] = "George"; values["LastName"] = "Bush"; values["Address1"] = "1600 Pennsylvania Ave."; values["Address2"] = "(c/o Laura)"; values["City"] = "Washington"; values["State"] = "DC"; values["Zip"] = "20500"; values["Phone"] = "202-456-1414"; values["Age"] = 0x39; theory.Populate(values, "%*%"); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string."); }
public void testTemplatePopulationWithBean() { string str = "Name: George BushAddress: 1600 Pennsylvania Ave. (c/o Laura), Washington, DC 20500Ph#: 202-456-1414Years old: 57"; StringTheory theory = new StringTheory("Name: FirstName LastNameAddress: Address1 Address2, City, State ZipPh#: PhoneYears old: Age"); theory.Populate(this.CreatePersonBean()); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string." + theory); }