public void testAppend() { string str = "xyzabc"; StringTheory theory = new StringTheory("xyz"); theory.Append("abc"); Assert.True(str.Equals(theory.ToString()), "simple string append failed:" + theory.ToString()); str = "xyzabc"; theory = new StringTheory("xyz"); StringTheory val = new StringTheory("abc"); theory.Append(val); Assert.True(str.Equals(theory.ToString()), "string theory append failed"); str = "xyzFooFooFoo"; theory = new StringTheory("xyz"); string[] strArray = new string[] { "Foo", "Foo", "Foo" }; theory.Append((object[])strArray); Assert.True(str.Equals(theory.ToString()), "string theory append(array) failed"); str = "xyzFooFooFoo"; theory = new StringTheory("xyz"); ArrayList list = new ArrayList(); list.Add("Foo"); list.Add("Foo"); list.Add("Foo"); theory.Append((ICollection)list); Assert.True(str.Equals(theory.ToString()), "string theory append(ArrayList) failed" + theory.ToString()); }
public string toSql() { StringTheory theory = new StringTheory(this); string phrase = "'"; theory.Replace(phrase, phrase + phrase); theory.SingleQuote(); return(theory.ToString()); }
protected XmlNode fetchNode(string nodePath) { StringTheory theory = new StringTheory(nodePath); if (theory.First() != '/') { theory.Prepend("/"); } return(this.doc.DocumentElement.SelectSingleNode(theory.ToString())); }
public override bool open(string configFile) { if (File.Exists(configFile)) { StringTheory theory = new StringTheory(); if (theory.LoadFile(configFile)) { XmlDocument boxInfo = new XmlDocument(); boxInfo.LoadXml(theory.ToString()); this.setFilenameUsingConfigXml(boxInfo); } } return(this.LoadXmlDocument()); }
protected bool LoadXmlDocument() { bool flag = false; if (File.Exists(this.Filename)) { StringTheory theory = new StringTheory(); if (theory.LoadFile(this.Filename)) { this.doc.LoadXml(theory.ToString()); flag = true; } } return(flag); }
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 XmlDocument Describe() { XmlDocument document = new XmlDocument(); StringTheory theory = new StringTheory("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); ArrayList list = new ArrayList(); theory.Append("<streams>\n"); this.ListStreams(list); foreach (Hashtable hashtable in list) { theory.Append(this.DescribeStream(hashtable["TABLE_NAME"].ToString())); } theory.Append("</streams>\n"); document.LoadXml(theory.ToString()); return(document); }
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 string getXml() { StringTheory theory = new StringTheory("<%islandName%>%body%</%islandName%>\n"); StringTheory val = new StringTheory(); StringTheory theory3 = new StringTheory(); foreach (string str in this.getFieldNames()) { val.Renew(" <%fieldName%>%fieldValue%</%fieldName%>\n"); val.Replace("%fieldName%", str.ToLower()); val.Replace("%fieldValue%", ((Field)this[str]).getValue()); theory3.Append(val); } theory.Replace("%islandName%", this.StreamName.ToLower()); theory.Replace("%body%", theory3); return(theory.ToString()); }
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 override bool open(string configFile) { bool flag = false; StringTheory theory = new StringTheory(); if (theory.LoadFile(configFile)) { XmlDocument info = new XmlDocument(); info.LoadXml(theory.ToString()); if (info != null) { StringTheory theory2 = new StringTheory("0" + this.GetConfigurationItem("max_connections", info)); this.Config.setDatabaseType(this.GetConfigurationItem("db_type", info.DocumentElement)); this.Config.setDriver(this.GetConfigurationItem("driver", info.DocumentElement)); this.Config.setMaxConnections(theory2.ToInt()); this.Config.setServer(this.GetConfigurationItem("server", info.DocumentElement)); this.Config.setDatabase(this.GetConfigurationItem("database", info.DocumentElement)); this.Config.setUser(this.GetConfigurationItem("user", info.DocumentElement)); this.Config.setPassword(this.GetConfigurationItem("password", info.DocumentElement)); flag = this.open(); } } return(flag); }
public void testJoin() { string str = "foo.foo.foo.foo.foo"; StringTheory theory = new StringTheory(); string[] strArray = new string[] { "foo", "foo", "foo", "foo", "foo" }; theory.Join(strArray, '.'); Assert.True(str.Equals(theory.ToString()), "1) Joined string doesn't match comparison"); theory = new StringTheory(); ArrayList list = new ArrayList(); list.Add("foo"); list.Add("foo"); list.Add("foo"); list.Add("foo"); list.Add("foo"); theory.Join(list, '.'); Assert.True(str.Equals(theory.ToString()), "2) Joined string doesn't match comparison"); }
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 testUpper() { string str = "ABCDEF"; StringTheory theory = new StringTheory("AbCDeF"); theory.Upper(); Assert.True(str.Equals(theory.ToString()), "uppered str doesn't match the comparison string!"); str = "AbCdEFG"; theory = new StringTheory("abcdefg"); theory.Upper(0); theory.Upper(2); theory.Upper(4); theory.Upper(5); theory.Upper(6); Assert.True(str.Equals(theory.ToString()), "uppered(idx) str doesn't match the comparison string!"); str = "abCDEfg"; theory = new StringTheory("abcdefg"); theory.Upper(2, 3); Assert.True(str.Equals(theory.ToString()), "uppered(idx, len) str doesn't match the comparison string!"); }
public void testProperWords() { string str = "Mares Eat Oats"; StringTheory theory = new StringTheory("mares eat oats"); theory.ProperWords(); Assert.True(str.Equals(theory.ToString()), "properWords failed?"); }
public void testRepeat() { string str = "Mares eat oats.Mares eat oats.Mares eat oats.Mares eat oats.Mares eat oats.Mares eat oats."; StringTheory theory = new StringTheory("Mares eat oats."); theory.Repeat(5); Assert.True(str.Equals(theory.ToString()), "Repeat 5 times doesn't match."); theory = new StringTheory("Mares eat oats."); theory.Repeat(0); Assert.True("Mares eat oats.".Equals(theory.ToString()), "Repeat 0 times doesn't match."); theory.Repeat(-1); Assert.True("Mares eat oats.".Equals(theory.ToString()), "Repeat -1 times doesn't match."); theory.Repeat(3); Assert.True("Mares eat oats.Mares eat oats.Mares eat oats.Mares eat oats.".Equals(theory.ToString()), "Repeat 3 times doesn't match."); }
public void testPadRight() { string str = "123456 "; StringTheory theory = new StringTheory("123456"); theory.PadRight(4); Assert.True(str.Equals(theory.ToString()), "padRight's result doesn't match the comparison string!"); str = "123456"; theory = new StringTheory("123456"); theory.PadRight(-1); Assert.True(str.Equals(theory.ToString()), "padRight failed using a bogus quantity"); str = "123456xxxx"; theory = new StringTheory("123456"); theory.PadRight(4, 'x'); Assert.True(str.Equals(theory.ToString()), "padRight failed while padding with a custom character"); }
public void testPrepend() { string str = "abcxyz"; StringTheory theory = new StringTheory("xyz"); theory.Prepend("abc"); Assert.True(str.Equals(theory.ToString()), "Simple string prepend failed"); str = "abcxyz"; theory = new StringTheory("xyz"); StringTheory theory2 = new StringTheory("abc"); theory.Prepend(theory2); Assert.True(str.Equals(theory.ToString()), "StringTheory prepend failed"); str = "FooFooFooxyz"; theory = new StringTheory("xyz"); string[] strArray = new string[] { "Foo", "Foo", "Foo" }; theory.Prepend((object[])strArray); Assert.True(str.Equals(theory.ToString()), "StringTheory prepend(array) failed"); str = "FooFooFooxyz"; theory = new StringTheory("xyz"); ArrayList list = new ArrayList(); list.Add("Foo"); list.Add("Foo"); list.Add("Foo"); theory.Prepend((ICollection)list); Assert.True(str.Equals(theory.ToString()), "StringTheory prepend(ArrayList) failed" + theory); }
public void testTrimLineEnds() { string str = "abcdef"; StringTheory theory = new StringTheory("abcdef\n"); theory.TrimLineEnds(); Assert.True(str.Equals(theory.ToString()), "failed on unix eol"); StringTheory theory2 = new StringTheory("abcdef\r\n"); theory2.TrimLineEnds(); Assert.True(str.Equals(theory2.ToString()), "failed on pc eol"); StringTheory theory3 = new StringTheory("abcdef\r"); theory3.TrimLineEnds(); Assert.True(str.Equals(theory3.ToString()), "failed on mac eol"); }
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 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 testCustomTemplatePopulationWithSpecificBean() { string str = "Name: George BushAddress: 1600 Pennsylvania Ave. (c/o Laura), Washington, DC 20500Product Number: 202-456-1Qty: 57"; StringTheory theory = new StringTheory("Name: $Built.Text.UnitTests.PersonBean.FirstName $Built.Text.UnitTests.PersonBean.LastNameAddress: $Built.Text.UnitTests.PersonBean.Address1 $Built.Text.UnitTests.PersonBean.Address2, $Built.Text.UnitTests.PersonBean.City, $Built.Text.UnitTests.PersonBean.State $Built.Text.UnitTests.PersonBean.ZipProduct Number: $Built.Text.UnitTests.OrderBean.ProductNumberQty: $Built.Text.UnitTests.OrderBean.Quantity"); theory.PopulateExact(this.CreatePersonBean(), "$*"); theory.PopulateExact(this.CreateOrderBean(), "$*"); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string."); }
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 testTrimRight() { string str = "abcdef"; StringTheory theory = new StringTheory("abcdef \t "); theory.TrimRight(); Assert.True(str.Equals(theory.ToString()), "trimmed str doesn't match the comparison string!"); }
public void testLeftJustify() { string str = "abcdef \t \t "; StringTheory theory = new StringTheory(" abcdef \t \t "); theory.LeftJustify(); Assert.True(str.Equals(theory.ToString()), "leftJustify str doesn't match the comparison string!"); theory.PasteOver(" "); theory.LeftJustify(); Assert.True(theory.Length == 6, "leftJustify str length isnt' right"); }
public void testDataIntegrity() { StringTheory theory = new StringTheory("0123456789"); Assert.True(theory.ToString().Equals("0123456789"), "Data in StringTheory is wrong"); }
public void testLower() { string str = "abcdef"; StringTheory theory = new StringTheory("AbCDeF"); theory.Lower(); Assert.True(str.Equals(theory.ToString()), "lowered str doesn't match the comparison string!"); str = "AbCdEFG"; theory = new StringTheory("ABCDEFG"); theory.Lower(1); theory.Lower(3); Assert.True(str.Equals(theory.ToString()), "lowered(idx) str doesn't match the comparison string!"); str = "ABcdeFG"; theory = new StringTheory("ABCDEFG"); theory.Lower(2, 3); Assert.True(str.Equals(theory.ToString()), "lowered(idx, len) str doesn't match the comparison string!"); }
public void testEllipsize() { string str = "MaresEatOatsAnd"; string str2 = "MaresEatOats..."; StringTheory theory = new StringTheory("MaresEatOatsAnd"); theory.Ellipsize(15); Assert.True(str.Equals(theory.ToString()), "str (1) doesn't match the comparison string!"); theory = new StringTheory("MaresEatOatsAndDoesEatOats"); theory.Ellipsize(15); Assert.True(str2.Equals(theory.ToString()), "str (2) doesn't match the ref2 string!"); }
public void testpasteOver() { string str = "MaresEatOats"; StringTheory theory = new StringTheory("MaresChowDownOnOats"); theory.PasteOver(5, 10, "Eat"); Assert.True(str.Equals(theory.ToString()), "overwritten (1) str doesn't match the comparison string!"); str = "MaresEatOats"; theory = new StringTheory("lorem ipsum"); theory.PasteOver("MaresEatOats"); Assert.True(str.Equals(theory.ToString()), "overwritten (2) str doesn't match the comparison string!"); }
public void testEscape() { string str = "a\\\"b\\\\cd\\\\e\\\"f"; StringTheory theory = new StringTheory("a\"b\\cd\\e\"f"); theory.Escape(); Assert.True(str.Equals(theory.ToString()), "str doesn't match the comparison string!"); }
public void testProper() { string str = "Thomas"; StringTheory theory = new StringTheory("THOMAS"); theory.Proper(); Assert.True(str.Equals(theory.ToString()), "proper str doesn't match the comparison string!"); }
public void testExpand() { string str = "abcdef "; StringTheory theory = new StringTheory("abcdef"); theory.Expand(10); Assert.True(str.Equals(theory.ToString()), "str doesn't match the comparison string!"); str = "abcdefyyyy"; theory = new StringTheory("abcdef"); theory.Expand(10, 'y'); Assert.True(str.Equals(theory.ToString()), "custom char didn't take"); }
public void testQuote() { string str = "\"abcdef\""; StringTheory theory = new StringTheory("abcdef"); theory.Quote(); Assert.True(str.Equals(theory.ToString()), "str 1 doesn't match the comparison string!"); str = "***abcdef***"; theory = new StringTheory("abcdef"); theory.Quote("***"); Assert.True(str.Equals(theory.ToString()), "str 2 doesn't match the comparison string!"); str = "|abcdef|"; theory = new StringTheory("abcdef"); theory.Quote('|'); Assert.True(str.Equals(theory.ToString()), "str 3 doesn't match the comparison string!"); }
public void testFill() { string str = "abcdefAAAAAAmnop"; StringTheory theory = new StringTheory("abcdefghijklmnop"); theory.Fill(6, 6, 'A'); Assert.True(str.Equals(theory.ToString()), "comparison after Fill failed"); }
public void testTemplatePopulationWithListOfSpecificBeans() { string str = "Name: George BushAddress: 1600 Pennsylvania Ave. (c/o Laura), Washington, DC 20500Product Number: 202-456-1Qty: 57"; StringTheory theory = new StringTheory("Name: %Built.Text.UnitTests.PersonBean.FirstName% %Built.Text.UnitTests.PersonBean.LastName%Address: %Built.Text.UnitTests.PersonBean.Address1% %Built.Text.UnitTests.PersonBean.Address2%, %Built.Text.UnitTests.PersonBean.City%, %Built.Text.UnitTests.PersonBean.State% %Built.Text.UnitTests.PersonBean.Zip%Product Number: %Built.Text.UnitTests.OrderBean.ProductNumber%Qty: %Built.Text.UnitTests.OrderBean.Quantity%"); object[] list = new object[] { this.CreatePersonBean(), this.CreateOrderBean() }; theory.PopulateExact(list, "%*%"); Assert.True(str.Equals(theory.ToString()), "Populated template doesn't match reference string." + theory); }
public void testFlip() { string str = "987654321"; StringTheory theory = new StringTheory("123456789"); theory.Flip(); Assert.True(str.Equals(theory.ToString()), "reverse results don't match the comparison string!" + theory); }
public void testCutThruLast() { string str = " Oats"; StringTheory theory = new StringTheory("Mares Eat Oats Mares Eat Oats"); string str2 = theory.CutThruLast("Eat"); Assert.True(str.Equals(theory.ToString()), "The resulting string is wrong."); Assert.True(str2.Equals("Mares Eat Oats Mares Eat"), "The emitted string is wrong."); theory.PasteOver("Mares Eat Oats"); string str3 = theory.CopyAfter("XYZ"); Assert.True("Mares Eat Oats".Equals(theory.ToString()), "[bogus] The resulting string is wrong."); Assert.True(str3.Length < 1, "[bogus] The Cut string is wrong."); }
public void testUnicode() { string str = "여보세요"; StringTheory theory = new StringTheory("여보세요 세계"); string str2 = theory.CutAfter("요"); Assert.True(str.Equals(theory.ToString()), "The resulting string is wrong."); Assert.True(str2.Equals(" 세계"), "The Cut string is wrong."); }