protected override void build(Item item, int limit) { string val = item.getStreamName(); string str2 = item.getIdField(); StringTheory condition = new StringTheory(); base.BuildCondition(condition, item); if (limit > -1) { StringTheory theory2 = new StringTheory("SELECT TOP %limit% %id_field% FROM %table%"); theory2.Replace("%limit%", limit); theory2.Replace("%id_field%", item.getIdField()); theory2.Replace("%table%", val); if ((condition != null) && (condition.Length > 0)) { theory2.Append(" WHERE "); theory2.Append(condition); } base.Append("DELETE FROM "); base.Append(val); base.Append(" WHERE "); base.Append(string.Concat(new object[] { item.getIdField(), " IN (", theory2, ")" })); } else { base.Append("DELETE FROM "); base.Append(val); if ((condition != null) && (condition.Length > 0)) { base.Append(" WHERE "); base.Append(condition); } } }
protected override void LimitRecordsReturned(StringTheory query, int limit) { if (limit > -1) { query.Prepend(query.CutThru("SELECT") + " TOP " + limit); } }
public bool build(Item item) { Hashtable hashtable = item.getBoxView(); Field field = (Field)hashtable[item.getIdField()]; if (!field.IsEmpty()) { Field field2 = null; ArrayList coll = new ArrayList(); foreach (string str in hashtable.Keys) { field2 = (Field)hashtable[str]; if (!str.Equals(item.getIdField()) && field2.Touched()) { coll.Add(str + "=" + field2.toSql()); } } if (coll.Count > 0) { StringTheory theory = new StringTheory(); theory.Join(coll, ", "); StringTheory val = new StringTheory("UPDATE %tableName% SET %pairListing% WHERE %idField% = %id%"); val.Replace("%tableName%", item.getStreamName()); val.Replace("%pairListing%", theory); val.Replace("%idField%", item.getIdField()); val.Replace("%id%", field.toSql()); base.Append(val); } } return(false); }
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()); }
protected override void build(Item entity, int limit) { string str = entity.getStreamName(); string str2 = entity.getIdField(); StringTheory condition = new StringTheory(); base.BuildCondition(condition, entity); OracleSelectQuery query = new OracleSelectQuery(entity, -1); base.Append("DELETE FROM " + str); if (condition.Length > 0) { base.Append(" WHERE " + condition); if (limit > -1) { base.Append(" AND rownum < "); base.Append(limit + 1); } } else if (limit > -1) { base.Append(" WHERE rownum < "); base.Append(limit + 1); } }
public Field(string name, string value) { this.Attributes = null; this.Name = new StringTheory(); this.Name.Renew(name); base.Renew(value); }
public bool createStream(Item item) { SqlBoxQuery query = new SqlBoxQuery(); if (item.UsesAutoId) { query.Append("CREATE TABLE %table%(%pk% int IDENTITY(1,1) PRIMARY KEY CLUSTERED%fields%)"); } else { query.Append("CREATE TABLE %table%(%pk% int PRIMARY KEY CLUSTERED%fields%)"); } string val = ", %name% varchar(255) DEFAULT NULL"; string strA = item.getIdField(); StringTheory theory = new StringTheory(); foreach (string str3 in item.getBoxView().Keys) { if (string.Compare(strA, str3, true) != 0) { theory.Append(val); theory.Replace("%name%", str3); } } query.Replace("%table%", item.getStreamName()); query.Replace("%pk%", strA); query.Replace("%fields%", theory); Console.WriteLine(query); this.SqlDatabase.process(query); return(this.streamExists(item)); }
public XmlDocument Describe(string streamName) { XmlDocument document = new XmlDocument(); StringTheory theory = new StringTheory("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); return(document); }
public bool build(Item item) { StringTheory theory = new StringTheory(); StringTheory theory2 = new StringTheory(); Field field = null; Hashtable hashtable = item.getBoxView(); ArrayList coll = new ArrayList(); ArrayList list2 = new ArrayList(); foreach (string str in hashtable.Keys) { field = (Field)hashtable[str]; if ((field != null) && field.Touched()) { coll.Add(str); list2.Add(field.toSql()); } } theory.Join(coll, ", "); theory2.Join(list2, ", "); if (coll.Count > 0) { StringTheory val = new StringTheory("INSERT INTO %tableName% (%fields%) VALUES (%values%)"); val.Replace("%tableName%", item.getStreamName()); val.Replace("%fields%", theory); val.Replace("%values%", theory2); base.Append(val); } return(false); }
public XmlDocument Describe(string streamName) { XmlDocument document = new XmlDocument(); StringTheory theory = new StringTheory("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); document.LoadXml(this.SqlDatabase.DescribeStream(streamName).ToString()); return(document); }
protected override void LimitRecordsReturned(StringTheory query, int limit) { if (limit > -1) { query.Append(" LIMIT "); query.Append(limit.ToString()); query.Append(" "); } }
public void build(Item item) { StringTheory val = new StringTheory("SELECT TOP 1 %idField% FROM %tableName% WHERE %idField% = '%id%'"); val.Replace("%idField%", item.getIdField()); val.Replace("%tableName%", item.getStreamName()); val.Replace("%id%", item.Id); base.Append(val); }
public string toSql() { StringTheory theory = new StringTheory(this); string phrase = "'"; theory.Replace(phrase, phrase + phrase); theory.SingleQuote(); return(theory.ToString()); }
public void testAsBase() { StringTheory theory = new StringTheory("11111111"); Assert.True(theory.AsBase(2) == 0xff, "Base 2 strings don't match"); Assert.True(theory.AsBase(8) == 0x249249, "Base 8 strings don't match"); Assert.True(theory.AsBase(0x10) == 0x11111111, "Base 16 strings don't match"); theory.PasteOver("111111"); Assert.True(theory.AsBase(0x1f) == 0, "Base 31 strings should yield zero." + theory.AsBase(0x1f)); }
protected override void LimitRecordsReturned(StringTheory query, int limit) { if (limit > -1) { query.Prepend("SELECT * FROM ("); query.Append(") WHERE rownum < "); query.Append((limit + 1).ToString()); query.Append(" "); } }
protected void AppendSortSpecification(StringTheory spec, Item entity) { ArrayList coll = entity.getSortList(); if (coll.Count > 0) { spec.Append(" ORDER BY "); spec.Join(coll, ", "); } }
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 void AppendSelectQuery(string tableName, StringTheory conditions, StringTheory specifiers, int limit) { StringTheory val = new StringTheory("SELECT * FROM %tableName% WHERE %conditions% %specifiers%"); if (conditions.IsEmpty()) { val.Replace("WHERE ", ""); } val.Replace("%tableName%", tableName); val.Replace("%conditions%", conditions); val.Replace("%specifiers%", specifiers); base.Append(val); this.LimitRecordsReturned(this, limit); }
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); }
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); }
public bool build(Item entity, int max) { base.Erase(); if (entity != null) { StringTheory condition = new StringTheory(); StringTheory spec = new StringTheory(); base.BuildCondition(condition, entity); if (entity.getSortList().Count > 0) { this.AppendSortSpecification(spec, entity); } this.AppendSelectQuery(entity.getStreamName(), condition, spec, max); } return(base.Length > 0); }
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 bool open(XmlNode boxInfo) { bool flag = false; if (boxInfo != null) { StringTheory theory = new StringTheory("0" + this.GetConfigurationItem("max_connections", boxInfo)); this.Config.setDatabaseType(this.GetConfigurationItem("db_type", boxInfo)); this.Config.setDriver(this.GetConfigurationItem("driver", boxInfo)); this.Config.setMaxConnections(theory.ToInt()); this.Config.setServer(this.GetConfigurationItem("server", boxInfo)); this.Config.setDatabase(this.GetConfigurationItem("database", boxInfo)); this.Config.setUser(this.GetConfigurationItem("user", boxInfo)); this.Config.setPassword(this.GetConfigurationItem("password", boxInfo)); flag = this.open(); } return(flag); }
protected override void build(Item item, int limit) { string val = item.getStreamName(); string str2 = item.getIdField(); StringTheory condition = new StringTheory(); base.BuildCondition(condition, item); base.Append("DELETE FROM "); base.Append(val); if ((condition != null) && (condition.Length > 0)) { base.Append(" WHERE "); base.Append(condition); } if (limit > -1) { base.Append(" LIMIT " + limit); } }
// Methods protected void BuildCondition(StringTheory condition, Item entity) { Hashtable hashtable = entity.getBoxView(); Field field = null; foreach (string str in hashtable.Keys) { field = (Field)hashtable[str]; if (field.Touched()) { if (condition.Length > 0) { condition.Append(" AND "); } if (field.Length < 1) { condition.Append(" ( len(" + str + ") < 1 or " + str + " IS NULL ) "); } else { condition.Append(str); condition.Append("="); condition.Append(field.toSql()); } } if (field.hasAttributes()) { string[] strArray = field.getAttributes(); for (int i = 0; i < strArray.Length; i++) { if (condition.Length > 0) { condition.Append(" AND "); } condition.Append(str); condition.Append(strArray[i]); } } } }
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 testLineCount() { StringTheory theory = new StringTheory("Line 1\r\nLine 2\r\nLine 3\r\n"); StringTheory theory2 = new StringTheory("Line 1\nLine 2\nLine 3\n"); StringTheory theory3 = new StringTheory("Line 1\rLine 2\rLine 3\r"); StringTheory theory4 = new StringTheory("Line 1\r\nLine 2\r\nLine 3"); StringTheory theory5 = new StringTheory("Line 1\nLine 2\nLine 3"); StringTheory theory6 = new StringTheory("Line 1\rLine 2\rLine 3"); Assert.True((theory2.Lines().Length == 3) && (theory5.Lines().Length == 3), "Wrong line count in {unix}: "); Assert.True((theory3.Lines().Length == 3) && (theory6.Lines().Length == 3), "Wrong line count in {mac}: "); Assert.True((theory.Lines().Length == 3) && (theory4.Lines().Length == 3), "Wrong line count in {pc}: " + theory.Lines().Length); }
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 testBeginsWith() { StringTheory theory = new StringTheory("0123456789"); Assert.True(theory.BeginsWith("0123") && !theory.BeginsWith("xxx"), "string starts differently?"); }
public void testMatches() { StringTheory theory = new StringTheory("0123456789"); Assert.True(theory.Rx.Matches(@"^\d+$"), "Pattern doesn't match!"); theory = new StringTheory("AbC123!!!"); Assert.True(theory.Rx.Matches("^[A].*"), "Second pattern doesn't match!"); }
public void testLoadFile() { StringTheory theory = new StringTheory(); Assert.True(theory.LoadFile(@"C:\Built\Products\StringTheory\1.4\C#\_development\StringTheory\Built\UnitTests\justify.txt"), "Couldn't load file?"); Assert.True(theory.Length > 0, "There should be some data in the file!"); Assert.True(theory.Lines().Length > 1, "There should be many lines in the file!"); }
public void testReplace() { StringTheory theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); StringTheory theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); int num = theory2.Replace("$", " "); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); num = theory2.Replace('$', ' '); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); num = theory2.Replace('$', " "); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); num = theory2.Replace("$", ' '); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); theory = new StringTheory("Lorem_$_ipsum._$_Ve_$_misdebus._$_U_$_misdebus._$_I_$_misdebus."); theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); num = theory2.Replace("$", "_$_"); Assert.True(theory2.Equals(theory), "(x)Chars didn't translate properly."); }
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 testPattern_CC_VISA() { StringTheory theory = new StringTheory(); theory.Renew("4111-1111-1111-1111"); Assert.True(theory.Rx.Matches(Credit.VISA), "VISA pattern 1 failed?" + Credit.VISA); theory.Renew("4111111111111111"); Assert.True(theory.Rx.Matches(Credit.VISA), "VISA pattern 2 failed"); theory.Renew("4111 1111 1111 1111"); Assert.True(theory.Rx.Matches(Credit.VISA), "VISA pattern 3 failed"); theory.Renew("123555-123xss"); this.AssertFalse("Non-VISA pattern 1 failed to be caught", theory.Rx.Matches(Credit.VISA)); theory.Renew("5111-1111-1111-1111"); this.AssertFalse("Non-VISA pattern 2 failed to be caught", theory.Rx.Matches(Credit.VISA)); }
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 testAsBase36() { StringTheory theory = new StringTheory("ZZZZ"); Assert.True(theory.AsBase36() == 0, "strings don't match"); }
public void testLast() { StringTheory theory = new StringTheory("xyzabc"); Assert.True(theory.Last() == 'c', "last char doesn't match comparison"); }
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 testPattern_US_SSN() { StringTheory theory = new StringTheory(); theory.Renew("555-55-5555"); Assert.True(theory.Rx.Matches(ID.SSN), "Perfect SSN pattern failed?"); theory.Renew("555555555"); Assert.True(theory.Rx.Matches(ID.SSN), "The imperfect SSN pattern failed"); theory.Renew("123555-123xss"); this.AssertFalse("Non-SSN pattern failed to be caught", theory.Rx.Matches(ID.SSN)); }
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 testIsDifferent() { string str = "Mares eat oats."; StringTheory theory = new StringTheory("XMares eat oatsX."); Assert.True(theory.Differs(str), "Strings don't contain same content"); }
// Methods public Field() { this.Attributes = null; this.Name = new StringTheory(); }
protected abstract void LimitRecordsReturned(StringTheory query, int limit);
public void testAsOct() { StringTheory theory = new StringTheory("7777"); Assert.True(theory.AsOct() == 0xfff, "strings don't match"); }
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 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 testPush() { StringTheory theory = new StringTheory(); Assert.True(theory.Push('m') == 1, "push is misreporting length!"); Assert.True(theory.Push('a') == 2, "push is misreporting length!"); Assert.True(theory.Push('r') == 3, "push is misreporting length!"); Assert.True(theory.Push('e') == 4, "push is misreporting length!"); Assert.True(theory.Push('s') == 5, "push is misreporting length!"); Assert.True(theory.Equals("mares"), "PUSH results didn't match expectations: " + theory); }
public void testIsUpper() { StringTheory theory = new StringTheory("mares EAT OATS"); Assert.True(theory.IsUpper(6, 8), "The specified range isn't upper case."); Assert.True(new StringTheory("MARES EAT OATS").IsUpper(), "The entire string isn't upper case."); this.AssertFalse("The entire string is lower case, but this is reporting it as upper case!", new StringTheory("mares eat oats").IsUpper()); theory = new StringTheory("mares eAt oats"); Assert.True(theory.IsUpper(7), "The spec'd char isn't upper case."); theory = new StringTheory("mares e-t oats"); this.AssertFalse("The spec'd non-alpha char was reported as upper case?", theory.IsUpper(7)); }
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 testIsSame() { string str = "Mares eat oats."; StringTheory theory = new StringTheory("Mares eat oats."); Assert.True(theory.SameAs(str), "Strings don't contain same content"); }
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 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 testLines() { string[] strArray = new StringTheory("Mares eat oats\nand does eat oats\nand little lambs eat ivy.\n").Lines(); Assert.True(strArray.Length == 3, "Wrong line count! - " + strArray.Length); }
public void testPattern_CC_AMEX() { StringTheory theory = new StringTheory(); theory.Renew("3411-111111-11111"); Assert.True(theory.Rx.Matches(Credit.AMEX), "AMEX pattern 1 failed?"); theory.Renew("341111111111111"); Assert.True(theory.Rx.Matches(Credit.AMEX), "AMEX pattern 2 failed"); theory.Renew("3711 111111 11111"); Assert.True(theory.Rx.Matches(Credit.AMEX), "AMEX pattern 3 failed"); theory.Renew("123555-123xss"); this.AssertFalse("Non-AMEX pattern 1 failed to be caught", theory.Rx.Matches(Credit.AMEX)); theory.Renew("4311-111111-11111"); this.AssertFalse("Non-AMEX pattern 2 failed to be caught", theory.Rx.Matches(Credit.AMEX)); }
public void testPattern_CC_MC() { StringTheory theory = new StringTheory(); theory.Renew("5111-1111-1111-1111"); Assert.True(theory.Rx.Matches(Credit.MC), "MC pattern 1 failed?"); theory.Renew("5511111111111111"); Assert.True(theory.Rx.Matches(Credit.MC), "MC pattern 2 failed"); theory.Renew("5311 1111 1111 1111"); Assert.True(theory.Rx.Matches(Credit.MC), "MC pattern 3 failed"); theory.Renew("123555-123xss"); this.AssertFalse("Non-MC pattern 1 failed to be caught", theory.Rx.Matches(Credit.MC)); theory.Renew("4111-1111-1111-1111"); this.AssertFalse("Non-MC pattern 2 failed to be caught", theory.Rx.Matches(Credit.MC)); }