public void Collision_Prevented_Priority() { using (var store = new CacheStore(NOPApplication.Instance)) { store.TableOptions.Register(new TableOptions("t1", 3, 7)); var tbl1 = store["t1"]; Aver.AreEqual(21, tbl1.Capacity); //because of the table size 3 x 7 both 0 and 21 map onto the same slot causing collision var obj1 = new businessObject { ID = 0, Name = "Suvorov-1", IsGood = true }; var obj2 = new businessObject { ID = 21, Name = "Kozloff-21", IsGood = false }; Aver.IsTrue(tbl1.Put(0, obj1, priority: 10)); //Suvorov has higher priority than Kozloff Aver.IsFalse(tbl1.Put(21, obj2)); //so collision does not happen Aver.AreEqual("Suvorov-1", tbl1.Get(0).ValueAs <businessObject>().Name); Aver.IsNull(tbl1.Get(21)); } }
public void Test01() { var app = new AzosApplication(null); Aver.IsTrue(app.Active); Aver.IsFalse(app.Stopping); Aver.IsFalse(app.ShutdownStarted); Aver.IsFalse(app.WaitForStopOrShutdown(100)); app.Stop(); Aver.IsFalse(app.Active); Aver.IsTrue(app.Stopping); Aver.IsFalse(app.ShutdownStarted); Aver.IsTrue(app.WaitForStopOrShutdown(100)); app.Dispose(); Aver.IsFalse(app.Active); Aver.IsTrue(app.Stopping); Aver.IsTrue(app.ShutdownStarted); Aver.IsTrue(app.WaitForStopOrShutdown(100)); }
public void RootCompositeWriteRead_PersonList() { var originalData = new List <TestPerson> { new TestPerson { Name = "Kolyan", DOB = DateTime.Now, Assets = 2000000, IsRegistered = true, Luck = 150.89 }, new TestPerson { Name = "Zmeyan", DOB = DateTime.Now.AddYears(-25), Assets = 50000000, IsRegistered = false, Luck = 283.4 }, }; var doc = new PortableObjectDocument(originalData); var convertedData = doc.ToOriginalObject() as List <TestPerson>; Aver.IsFalse(object.ReferenceEquals(originalData, convertedData)); Aver.AreEqual(originalData.Count, convertedData.Count); Aver.IsTrue(originalData[0].Equals(convertedData[0])); Aver.IsTrue(originalData[1].Equals(convertedData[1])); }
public void EC_WebApp1_WMED0004() { { var host = Metabase.CatalogReg.NavigateHost(WMED0004); var conf = host.GetEffectiveAppConfig("WebApp1"); Aver.AreEqual("WebApp1", conf.Navigate("/$application-name").Value); Aver.AreEqual("wmed0004", conf.Navigate("/$name").Value); Aver.AreEqual("Popov", conf.Navigate("/$clown").Value); Aver.AreEqual("A", conf.Navigate("/gv/$a").Value); Aver.AreEqual("B", conf.Navigate("/gv/$b").Value); Aver.AreEqual("da", conf.Navigate("/glue/$zoloto").Value); Aver.AreEqual("da", conf.Navigate("/glue/$serebro").Value); Aver.AreEqual(123, conf.Navigate("/east-block/$something").ValueAsInt()); Aver.AreEqual(true, conf.Navigate("/cleveland/$solon").ValueAsBool()); Aver.AreEqual(true, conf.Navigate("/cleveland/$hudson").ValueAsBool()); Aver.IsFalse(conf.Navigate("/windows7/$build").Exists); } }
public void ValueLists_Reset() { var schema = Schema.GetForTypedDoc <ValListDoc>(); Aver.AreEqual(2, schema.FieldCount); var def1 = schema["Data1"]; Aver.IsNotNull(def1); Aver.IsTrue(def1[null].HasValueList); Aver.IsTrue(def1["L1"].HasValueList); Aver.IsTrue(def1["L2"].HasValueList); Aver.IsTrue(def1["L3"].HasValueList); Aver.IsFalse(def1["L4"].HasValueList); Aver.IsTrue(def1["L5"].HasValueList); Aver.AreEqual(4, def1[null].ParseValueList().Count); Aver.AreEqual(4, def1["L1"].ParseValueList().Count); Aver.AreEqual(5, def1["L2"].ParseValueList().Count); Aver.AreEqual(5, def1["L3"].ParseValueList().Count); Aver.AreEqual(0, def1["L4"].ParseValueList().Count); Aver.AreEqual(2, def1["L5"].ParseValueList().Count); Aver.AreEqual("apple", def1[null].ParseValueList()["a"].AsString()); Aver.AreEqual("advaita", def1["L1"].ParseValueList()["a"].AsString()); Aver.AreEqual("advaita", def1["L2"].ParseValueList()["a"].AsString()); Aver.AreEqual("advaita", def1["L3"].ParseValueList()["a"].AsString()); Aver.IsNull(def1["L4"].ParseValueList()["a"]); Aver.AreEqual("another", def1["L5"].ParseValueList()["a"].AsString()); Aver.AreEqual("zukini", def1[null].ParseValueList()["z"].AsString()); Aver.AreEqual(null, def1["L1"].ParseValueList()["z"].AsString()); Aver.AreEqual("zoom", def1["L2"].ParseValueList()["z"].AsString()); Aver.AreEqual("zoom", def1["L3"].ParseValueList()["z"].AsString()); Aver.AreEqual(null, def1["L4"].ParseValueList()["z"].AsString()); Aver.AreEqual("zima", def1["L5"].ParseValueList()["z"].AsString()); }
public void IsOneOf_Enumerable() { Aver.IsTrue("abc".IsOneOf(new List <string> { "abc" })); Aver.IsTrue("abc".IsOneOf(new List <string> { "def", "abc" })); Aver.IsTrue(((string)null).IsOneOf(new List <string> { "abc", null })); Aver.IsTrue("abC".IsOneOf(new List <string> { "aBc" })); Aver.IsTrue("zUZA".IsOneOf(new List <string> { "aBc", "def", "weqrqwrqwrqwer", "zuza" })); Aver.IsFalse(((string)null).IsOneOf((List <string>)null)); Aver.IsFalse("aaa".IsOneOf((List <string>)null)); Aver.IsFalse(((string)null).IsOneOf(new List <string> { "abc", "def" })); Aver.IsFalse("def".IsOneOf(new List <string> { "abc", "fed", "diff" })); Aver.IsFalse(" def ".IsOneOf(new List <string> { "abc", "def", "diff" })); Aver.IsFalse("def".IsOneOf(new List <string> { "abc", " def ", "diff" })); Aver.IsTrue("def".IsOneOf(new List <string> { "abc", "def", "diff" })); }
public void Rowset_FromJSON_FieldMissed(bool rowsAsMap) { var row = new Person { Name = "Henry", Age = 43 }; var rowSet = new Rowset(row.Schema); rowSet.Add(row); var options = new Azos.Serialization.JSON.JsonWritingOptions { RowsetMetadata = true, RowsAsMap = rowsAsMap }; var json = rowSet.ToJson(options); var map = JsonReader.DeserializeDataObject(json) as JsonDataMap; var rows = (map["Rows"] as IList <object>); if (rowsAsMap) { var pers = rows[0] as IDictionary <string, object>; pers.Remove("Age"); } else { var pers = rows[0] as IList <object>; pers.RemoveAt(1); } var trg = RowsetBase.FromJSON(map, out bool allMatched); Aver.IsFalse(allMatched); var trgRow = trg[0]; Aver.AreEqual(trgRow.Schema.FieldCount, 2); Aver.AreObjectsEqual(trgRow["Name"], "Henry"); Aver.IsNull(trgRow["Age"]); }
public void ErlPortTest() { var t = new ErlPort("test", 10, 1); Aver.IsTrue(t.Equals(new ErlPort("test", 10, 1))); Aver.AreObjectsEqual(t, new ErlPort("test", 10, 1)); Aver.AreEqual(1, new ErlPort("tesu", 10, 1).CompareTo(t)); Aver.AreEqual(-1, new ErlPort("tess", 10, 1).CompareTo(t)); Aver.AreEqual(-1, new ErlPort("test", 9, 1).CompareTo(t)); Aver.AreEqual(1, new ErlPort("test", 12, 1).CompareTo(t)); Aver.AreEqual(-1, new ErlPort("test", 10, 0).CompareTo(t)); Aver.AreEqual(1, new ErlPort("test", 10, 2).CompareTo(t)); Aver.AreEqual("#Port<test.10>", t.ToString()); Aver.AreEqual("#Port<test.10>", t.ValueAsString); Aver.IsTrue(t.IsScalar); Aver.IsTrue(ErlTypeOrder.ErlPort == t.TypeOrder); Aver.IsTrue(t.Matches(new ErlPort("test", 10, 1))); Aver.IsTrue(new ErlVarBind().SequenceEqual(t.Match(new ErlPort("test", 10, 1)))); doesNotThrow(() => { var x = t.ValueAsObject; }); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsInt; }); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsLong; }); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsDecimal; }); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsDateTime; }); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsTimeSpan; }); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsDouble; }); Aver.AreEqual("#Port<test.10>", t.ValueAsString); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsBool; }); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsChar; }); Aver.Throws <ErlIncompatibleTypesException>(() => { var x = t.ValueAsByteArray; }); IErlObject temp = null; Aver.IsFalse(t.Subst(ref temp, new ErlVarBind())); Aver.IsTrue(t.Visit(false, (acc, o) => acc |= o is ErlPort)); }
public void RootCompositeWriteRead_Family() { var originalData = new TestFamily { Husband = new TestPerson { Name = "Kolyan", DOB = DateTime.Now, Assets = 2000000, IsRegistered = true, Luck = 150.5489 }, Wife = new TestPerson { Name = "Feiga", DOB = DateTime.Now, Assets = 578, IsRegistered = false, Luck = 250.489 }, Kid = new TestPerson { Name = "Yasha", DOB = DateTime.Now, Assets = 12, IsRegistered = true, Luck = 350.189 }, }; var doc = new PortableObjectDocument(originalData); var convertedData = doc.ToOriginalObject() as TestFamily; Aver.IsFalse(object.ReferenceEquals(originalData, convertedData)); Aver.IsTrue(originalData.Equals(convertedData)); }
public void Collision() { using (var store = new CacheStore(null)) { store.TableOptions.Register(new TableOptions("t1", 3, 7)); var tbl1 = store["t1"]; Aver.AreEqual(21, tbl1.Capacity); var obj1 = new businessObject { ID = 0, Name = "Suvorov-1", IsGood = true }; var obj2 = new businessObject { ID = 21, Name = "Kozloff-21", IsGood = false }; //because of the table size 3 x 7 both 0 and 21 map onto the same slot causing collision Aver.IsTrue(tbl1.Put(0, obj1)); Aver.IsFalse(tbl1.Put(21, obj2)); Aver.IsNull(tbl1.Get(0)); Aver.AreEqual("Kozloff-21", tbl1.Get(21).ValueAs <businessObject>().Name); } }
public void MatchNames() { var config = @"nfx { a { name=Peter channel-name=Twilio channel-address=+15005550005 } a { name=Nick channel-name=Mailgun [email protected] } a { name=Ann channel-name=SMTP [email protected] } }"; var builder = new MessageAddressBuilder(config); var names = new string[] { "smtp" }; Aver.IsTrue(builder.MatchNamedChannel(names)); names = new string[] { "Twilio", "MailGun" }; Aver.IsTrue(builder.MatchNamedChannel(names)); names = new string[] { "Skype" }; Aver.IsFalse(builder.MatchNamedChannel(names)); }
public void SocialProviderProperties() { var conf = @"nfx { web-settings { social { provider {type='NFX.Web.Social.GooglePlus, NFX.Web' client-code='111111111111' client-secret='a1111111111-a11111111111' web-service-call-timeout-ms='20000' keep-alive='false' pipelined='false'} provider {type='NFX.Web.Social.Facebook, NFX.Web' client-code='1111111111111111' client-secret='a1111111111111111111111111111111' app-accesstoken='a|111111111111111111111111111111111111111111'} } } }".AsLaconicConfig(); using (new NFX.ApplicationModel.ServiceBaseApplication(new string[] { }, conf)) { var social = WebSettings.SocialNetworks; Aver.AreEqual(2, social.Count); var instantiatedGooglePlus = ((GooglePlus)social["GooglePlus"]); Aver.AreEqual(20000, instantiatedGooglePlus.WebServiceCallTimeoutMs); Aver.IsFalse(instantiatedGooglePlus.KeepAlive); Aver.IsFalse(instantiatedGooglePlus.Pipelined); var instantiatedFacebook = ((Facebook)social["Facebook"]); Aver.AreEqual(SocialNetwork.DEFAULT_TIMEOUT_MS_DEFAULT, instantiatedFacebook.WebServiceCallTimeoutMs); Aver.IsTrue(instantiatedFacebook.KeepAlive); Aver.IsTrue(instantiatedFacebook.Pipelined); } }
public void SetCountLimit_Throw() { var sut = new CappedQueue <MyItem>(i => i == null ? 0 : i.Name == null ? 0 : i.Name.Length) { CountLimit = 3, Handling = QueueLimitHandling.Throw }; Aver.IsTrue(sut.TryEnqueue(new MyItem { Name = "Cat" })); Aver.AreEqual(1, sut.Count); Aver.IsTrue(sut.TryEnqueue(new MyItem { Name = "Dog" })); Aver.AreEqual(2, sut.Count); Aver.IsTrue(sut.TryEnqueue(null)); Aver.AreEqual(3, sut.Count); try { //Rabbit will not fit - will throw Aver.IsFalse(sut.TryEnqueue(new MyItem { Name = "Rabbit" })); } catch (AzosException error) { Aver.IsTrue(error.Message.Contains("limit is reached")); Conout.WriteLine("Expected and got: " + error.ToMessageWithType()); return; } Aver.Fail(Constants.ERR_NOT_THROWN); }
public void Glue_SerializeDeserialize() { var frm1 = new WireFrame(123, false, FID.Generate()); Aver.AreEqual(WireFrame.FRAME_LENGTH, frm1.Length); var ms = new MemoryStream(); Aver.AreEqual(WireFrame.FRAME_LENGTH, frm1.Serialize(ms)); ms.Position = 0; var frm2 = new WireFrame(ms); Aver.IsTrue(frm1.Type == frm2.Type); Aver.AreEqual(frm1.RequestID, frm2.RequestID); Aver.AreEqual(frm1.OneWay, frm2.OneWay); Aver.AreEqual(frm1.Length, frm2.Length); Aver.AreEqual(frm1.Format, frm2.Format); Aver.AreEqual(frm1.HeadersContent, frm2.HeadersContent); Aver.IsFalse(frm2.OneWay); }
public void T1_ResetCallBatch() { using (var ms = new MemoryStream()) { var s1 = new SlimSerializer(); s1.TypeMode = TypeRegistryMode.Batch; Aver.IsTrue(TypeRegistryMode.Batch == s1.TypeMode); Aver.IsFalse(s1.IsThreadSafe); Aver.IsFalse(s1.BatchTypesAdded); var o1 = new A1 { I1 = 12 }; s1.Serialize(ms, o1); Aver.IsTrue(s1.BatchTypesAdded); s1.ResetCallBatch(); Aver.IsFalse(s1.BatchTypesAdded); } }
public void Of_3() { var cfg = "a=-1 b=-2".AsLaconicConfig(); Aver.IsTrue(cfg.Of("a", "z", "_").Exists); Aver.IsTrue(cfg.Of("z", "_", "a").Exists); Aver.IsTrue(cfg.Of("z", "a", "_").Exists); Aver.IsTrue(cfg.Of("b", "z", "_").Exists); Aver.IsTrue(cfg.Of("z", "_", "b").Exists); Aver.IsTrue(cfg.Of("z", "b", "_").Exists); Aver.IsFalse(cfg.Of("dont-exist", "z", "_").Exists); Aver.IsFalse(cfg.Of("dont-exist", "_", "z").Exists); Aver.AreSameRef(cfg.AttrByName("a"), cfg.Of("a", "z", "_")); Aver.AreSameRef(cfg.AttrByName("a"), cfg.Of("z", "_", "a")); Aver.AreSameRef(cfg.AttrByName("b"), cfg.Of("b", "z", "_")); Aver.AreSameRef(cfg.AttrByName("b"), cfg.Of("z", "b", "_")); Aver.AreSameRef(cfg.AttrByName("b"), cfg.Of("z", "_", "b")); Aver.AreEqual(-1, cfg.Of("z", "A", "_").ValueAsInt()); Aver.AreEqual(-1, cfg.Of("A", "_", "z").ValueAsInt()); Aver.AreEqual(-2, cfg.Of("z", "_", "B").ValueAsInt()); Aver.AreEqual(-2, cfg.Of("B", "z", "_").ValueAsInt()); }
public void Metadata_Basic() { var ms = new MemoryStream(); var meta = VolumeMetadataBuilder.Make("Volume-1", "none") .SetVersion(123, 456) .SetDescription("My volume"); var v1 = new DefaultVolume(CryptoMan, meta, ms); var id = v1.Metadata.Id; v1.Dispose();//it closes the stream Aver.IsTrue(ms.Length > 0); var v2 = new DefaultVolume(CryptoMan, ms); Aver.AreEqual(id, v2.Metadata.Id); Aver.AreEqual("Volume-1", v2.Metadata.Label); Aver.AreEqual("My volume", v2.Metadata.Description); Aver.AreEqual(123, v2.Metadata.VersionMajor); Aver.AreEqual(456, v2.Metadata.VersionMinor); Aver.IsTrue(v2.Metadata.Channel.IsZero); Aver.IsFalse(v2.Metadata.IsCompressed); Aver.IsFalse(v2.Metadata.IsEncrypted); }
public void AppCat_MatchPackageBinaries() { var app = Metabase.CatalogApp.Applications["TestApp"]; var bins = app.MatchPackageBinaries("fedora20").ToList(); Aver.AreEqual(3, bins.Count); Aver.AreEqual("TestPackage1", bins[0].Name); Aver.AreEqual(Metabank.DEFAULT_PACKAGE_VERSION, bins[0].Version); Aver.IsFalse(bins[0].MatchedPackage.IsAnyPlatform); Aver.AreEqual("linux64", bins[0].MatchedPackage.Platform); Aver.IsTrue(bins[0].MatchedPackage.IsAnyOS); Aver.AreEqual("TestPackage2", bins[1].Name); Aver.AreEqual("older", bins[1].Version); Aver.IsTrue(bins[1].MatchedPackage.IsAnyPlatform); Aver.IsTrue(bins[1].MatchedPackage.IsAnyOS); Aver.AreEqual("TestPackage3", bins[2].Name); Aver.AreEqual(Metabank.DEFAULT_PACKAGE_VERSION, bins[2].Version); Aver.IsTrue(bins[2].MatchedPackage.IsAnyPlatform); Aver.IsTrue(bins[2].MatchedPackage.IsAnyOS); }
public void DetectSimbolPair() { var enumerator = @" """" ".AsLookAheadEnumerable().GetLookAheadEnumerator(); var detect = false; while (!detect && enumerator.MoveNext()) { if ('\"' == enumerator.Current && enumerator.HasNext && '\"' == enumerator.Next) { detect = true; } } Aver.IsTrue(detect); enumerator = @""" """.AsLookAheadEnumerable().GetLookAheadEnumerator(); detect = false; while (!detect && enumerator.MoveNext()) { if ('\"' == enumerator.Current && enumerator.HasNext && '\"' == enumerator.Next) { detect = true; } } Aver.IsFalse(detect); }
public void TryParse() { Aver.IsTrue(SysAuthToken.TryParse(null, out var got)); Aver.IsFalse(got.Assigned); Aver.IsTrue(SysAuthToken.TryParse("", out got)); Aver.IsFalse(got.Assigned); Aver.IsTrue(SysAuthToken.TryParse("frog::toad", out got)); Aver.AreEqual("frog", got.Realm); Aver.AreEqual("toad", got.Data); Aver.IsFalse(SysAuthToken.TryParse("::toad", out got)); Aver.IsFalse(got.Assigned); Aver.IsFalse(SysAuthToken.TryParse("frog::", out got)); Aver.IsFalse(got.Assigned); Aver.IsFalse(SysAuthToken.TryParse("frogtoad", out got)); Aver.IsFalse(got.Assigned); Aver.IsFalse(SysAuthToken.TryParse("sys:lll", out got)); Aver.IsFalse(got.Assigned); }
public void StringMap_TwoRefOne_InClass() { using (var ms = new MemoryStream()) { var s = new SlimSerializer(); var dIn = new stringMapCls { Map1 = new StringMap(false) { { "a", "Alex" }, { "b", "Boris" } } }; dIn.Map2 = dIn.Map1; //SAME REF! s.Serialize(ms, dIn); ms.Seek(0, SeekOrigin.Begin); var dOut = (stringMapCls)s.Deserialize(ms); Aver.IsNotNull(dOut); Aver.IsNotNull(dOut.Map1); Aver.IsNotNull(dOut.Map2); Aver.IsTrue(object.ReferenceEquals(dOut.Map1, dOut.Map2));//IMPORTANT! Aver.IsFalse(dOut.Map1.CaseSensitive); Aver.AreEqual(2, dOut.Map1.Count); Aver.AreEqual("Alex", dOut.Map1["a"]); Aver.AreEqual("Alex", dOut.Map1["A"]); Aver.AreEqual("Boris", dOut.Map1["b"]); Aver.AreEqual("Boris", dOut.Map1["B"]); } }
public void MatchPattern5() { Aver.IsTrue("some address".MatchPattern("s?me*addre??")); Aver.IsFalse("some adzress".MatchPattern("s?me*addre??")); }
public void MatchPattern7() { Aver.IsTrue("same AddreZZ".MatchPattern("s?me*addre??")); Aver.IsFalse("same AddreZZ?".MatchPattern("s?me*addre??")); Aver.IsFalse("same AddreZ".MatchPattern("s?me*addre??")); }
public void CheckPhone() { string[] good = { "(800) 234-2345x234", "(800) 234-2345", "800 2345678", "800 234-4522", "800.2345678", "800.234.4522", "800-234-2345", "800-234-2345x234", "8882344511", "(888)2344511", "(888)234-4511", "(888)234.4511", "(888) 2344511", "(888) 234 4511", "(900) 4megood", "9004megood", "+28937498723987498237", "+8293 823098 82394", "+3423-3423-234-34", "+3423-3423-234x456", "+1 900 4ME-GOOD" }; string[] bad = { "800", "(800)", "(8888)234-4511", " (888)234-4511", "(888)234-4511 ", "(8-88)234-4511", "+1423423 +23423", ")800 23456777(", "800)1234567", "(216) 234(2345)", "345#aaaaa", "7567:242333", "+800242--3333", "+800242..3333", "+800242-.3333", "#800242.-3333", "+800242.-3333", "+(80 0)242.-3333", "(800).2423333", "(800)-2423333", "(800)2423333.", ".(800)2423333", "-(800)2423333", "((800))2423333", "(800-)2423333", "(.800)2423333", "+(800)242-3333", "(800)242. 3333", "(800)242 - 3333", "(800)242 COOL", "(800)242 - 33 - 33" }; Console.WriteLine("Good numbers:"); for (int i = 0; i < good.Length; i++) { Console.WriteLine(good[i]); Aver.IsTrue(DataEntryUtils.CheckTelephone(good[i])); } Console.WriteLine("Bad numbers:"); for (int i = 0; i < bad.Length; i++) { Console.WriteLine(bad[i]); Aver.IsFalse(DataEntryUtils.CheckTelephone(bad[i])); } }
public void MatchPattern4() { Aver.IsTrue("some address".MatchPattern("s?me*")); Aver.IsFalse("sone address".MatchPattern("s?me*")); }
public void CheckEmail() { string[] validEMails = { "*****@*****.**", "*****@*****.**", "*****@*****.**", "user@com", "*****@*****.**", "юзер@мояпочта.ры", "#!$%&'*+-/=?^_`{}|[email protected]", "*****@*****.**", "*****@*****.**", "user#[email protected]", "*****@*****.**", "user@example--com", "[email protected]", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" }; Console.WriteLine("==== Valid emails ===="); foreach (var email in validEMails) { Console.WriteLine(email); Aver.IsTrue(DataEntryUtils.CheckEMail(email)); } Console.WriteLine("==== Invlaid emails ===="); string[] invalidEMails = { " ", "@", "user@ ", "user@", " @example.com", "@example.com", ".@.", "dima@[email protected]", "dima [email protected]", "user", "user2example.com", "*****@*****.**", "*****@*****.**", "[email protected].", "*****@*****.**", "*****@*****.**", "*****@*****.**", "user @example.com", "[email protected] ", "user@ example.com", "us [email protected]", "user@example com", "user@example .com", "[email protected]", "*****@*****.**", "*****@*****.**", "user@examplecom-", "*****@*****.**", "*****@*****.**", "us@[email protected]", "user#example.com", "user@example/com", @"us\[email protected]", @"user@exa\mple.com", "us([email protected]", "user(comment)@example.com", "user@exa(mple.com", "us)[email protected]", "user@exa)mple.com", "us,[email protected]", "user@exa,mple.com", "us:[email protected]", "user@exa:mple.com", "us;[email protected]", "user@exa;mple.com", "us<*****@*****.**", "user@exa<mple.com", "us>[email protected]", "user@exa>mple.com", "us[[email protected]", "user@exa[mple.com", "us][email protected]", "user@exa]mple.com", "user@exam-_ple.com" }; foreach (var email in invalidEMails) { Console.WriteLine(email); Aver.IsFalse(DataEntryUtils.CheckEMail(email)); } }
public void MatchPattern30() { Aver.IsTrue("kikimora zhaba fly snake toad".MatchPattern("*?ly*")); Aver.IsFalse("kikimora zhaba fly snake toad".MatchPattern("*?ly")); Aver.IsTrue("kikimora zhaba fly snake toad".MatchPattern("*?ly*toad")); }
public void MatchPattern29() { Aver.IsTrue("Honda buick honda monda donda ford buick ford fORd".MatchPattern("*buick*")); Aver.IsFalse("Honda buick honda monda donda ford buick ford fORd".MatchPattern("*buick handa*")); Aver.IsTrue("Honda buick honda monda donda ford buick ford fORd".MatchPattern("*buick h?nda*")); }
public void MatchPattern28() { Aver.IsTrue("Honda buick honda monda donda ford buick ford fORd".MatchPattern("*ford")); Aver.IsFalse("Honda buick honda monda donda ford buick ford fORd".MatchPattern("*ford", senseCase: true)); Aver.IsTrue("Honda buick honda monda donda ford buick ford fORd".MatchPattern("*fORd", senseCase: true)); }
public void MatchPattern27() { Aver.IsTrue("Honda buick honda monda donda ford buick ford ford".MatchPattern("*ford")); Aver.IsFalse("Honda buick honda monda donda ford buick ford ford".MatchPattern("*honda")); Aver.IsTrue("Honda buick honda monda donda ford buick ford ford".MatchPattern("*honda*")); }