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 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 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 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)); }
public void testCut() { StringTheory theory = new StringTheory("0123456789"); string str = theory.Cut(4, 4); Assert.True(str.Length == 4, "Copied string length is wrong!"); Assert.True(theory.Length == 6, "Original StringTheory length is wrong!"); theory.Renew(""); Assert.True(theory.Cut(0, 1).Equals(""), "bogus Cut didn't return empty."); theory.Renew(""); Assert.True(theory.Cut(0, -1).Equals(""), "bogus Cut (2) didn't return empty."); }
public void testFormat() { StringTheory theory = new StringTheory("341111111111111"); if (!theory.Equals("3411-111111-11111")) { theory.Format("####-######-#####"); } Assert.True(theory.Equals("3411-111111-11111"), "AMEX Format didn't work:" + theory); StringTheory theory2 = new StringTheory("18003334456"); if (!theory2.Equals("1-800-333-4456")) { theory2.Format("#-###-###-####"); } Assert.True(theory2.Equals("1-800-333-4456"), "Phone Format didn't work:" + theory2); theory2.Renew("18003334456"); theory2.Format(""); Assert.True(theory2.Equals("18003334456"), "Format failed when given a blank Format. It *should* pass thru." + theory2); }
public void testToLong() { StringTheory theory = new StringTheory("966700004"); long num = theory.ToLong(); Assert.True(0x399eabe4L == num, "strings don't match"); theory.Renew(""); Assert.True(0L == theory.ToLong(), "value should be zero"); }
public void testToInt() { StringTheory theory = new StringTheory("056701"); int actual = theory.ToInt(); Assert.AreEqual(0xdd7d, actual, "strings don't match"); theory.Renew(""); Assert.True(0 == theory.ToInt(), "value should be zero"); }
public void testToFloat() { StringTheory theory = new StringTheory("4367.002"); float num = theory.ToFloat(); float num2 = 4367.002f; Assert.True(num2 == num, "strings don't match"); theory.Renew(""); Assert.True(0f == theory.ToFloat(), "value should be zero"); }
public void testToDouble() { StringTheory theory = new StringTheory("966700004"); double num = theory.ToDouble(); Assert.True(966700004.0 == num, "strings don't match"); theory.Renew(""); Assert.True(0.0 == theory.ToDouble(), "value should be zero"); }
public void testScrub() { StringTheory theory = new StringTheory("%555-33-0000*"); theory.Filter("-.$%*"); Assert.True(theory.Equals("555330000"), "Scrub(1) failed: " + theory); theory.Renew("%555-33-0000*"); theory.Filter("-"); Assert.True(theory.Equals("%555330000*"), "Scrub(2) failed: " + theory); }