GlobTest.cs :  » Development » AdblockIE » af0 » Adblock » UnitTests » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » AdblockIE 
AdblockIE » af0 » Adblock » UnitTests » GlobTest.cs
using af0.Adblock;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace af0.Adblock.UnitTests{
    /// <summary>
    ///This is a test class for GlobTest and is intended
    ///to contain all GlobTest Unit Tests
    ///</summary>
    [TestClass()]
    public class GlobTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestMethod()]
        public void LiteralTest()
        {
            Glob target = new Glob("hamandeggs");
            Assert.IsTrue(target.IsMatch("hamandeggs")); // a literal should be matched
            Assert.IsTrue(target.IsMatch("HAMANDEGGS")); // as should be capitals
            Assert.IsTrue(target.IsMatch("HaMaNDeggS")); // or mixed case
            Assert.IsFalse(target.IsMatch("spamhamandeggs")); // without a star, this shouldn't match
            Assert.IsFalse(target.IsMatch("hamandeggsandspam"));
            Assert.IsFalse(target.IsMatch("spamhamandeggsandbacon")); // nor these two
            Assert.IsFalse(target.IsMatch("")); // just to be on the safe side
            Assert.IsFalse(target.IsMatch("and")); // substrings are never matches
        }

        [TestMethod()]
        public void StarTest()
        {
            Glob target = new Glob("*");
            Assert.IsTrue(target.IsMatch(""));
            Assert.IsTrue(target.IsMatch("*"));
            Assert.IsTrue(target.IsMatch("hamANDeggs"));
            target = new Glob("ham*");
            Assert.IsTrue(target.IsMatch("ham"));
            Assert.IsTrue(target.IsMatch("hamandeggs"));
            Assert.IsFalse(target.IsMatch("eggshamandeggs"));
            target = new Glob("*eggs");
            Assert.IsTrue(target.IsMatch("hamandeggs"));
            Assert.IsTrue(target.IsMatch("eggs"));
            Assert.IsFalse(target.IsMatch("hamandeggsandbacon"));
            target = new Glob("ham*eggs");
            Assert.IsTrue(target.IsMatch("hamandeggs"));
            Assert.IsTrue(target.IsMatch("hameggs"));
            Assert.IsFalse(target.IsMatch("ham"));
            Assert.IsFalse(target.IsMatch("eggs"));
        }

        [TestMethod()]
        public void QmarkTest()
        {
            Glob target = new Glob("?");
            Assert.IsTrue(target.IsMatch("h"));
            Assert.IsFalse(target.IsMatch("ham"));
            Assert.IsFalse(target.IsMatch(""));
            target = new Glob("ham?");
            Assert.IsTrue(target.IsMatch("hama"));
            Assert.IsFalse(target.IsMatch("hamand"));
        }

        [TestMethod()]
        public void ComboTest()
        {
            Glob target = new Glob("*?eggs");
            Assert.IsTrue(target.IsMatch("hamandeggs"));
            Assert.IsFalse(target.IsMatch("eggs"));
            target = new Glob("ham?*");
            Assert.IsTrue(target.IsMatch("hamandeggs"));
            Assert.IsFalse(target.IsMatch("ham"));
        }

        [TestMethod()]
        public void EscapeTest()
        {
            Glob target = new Glob(@"ham\?");
            Assert.IsTrue(target.IsMatch("ham?"));
            Assert.IsFalse(target.IsMatch("ham"));
            Assert.IsFalse(target.IsMatch("hama"));
            target = new Glob(@"eggs\*");
            Assert.IsTrue(target.IsMatch("eggs*"));
            Assert.IsFalse(target.IsMatch("eggs"));
            Assert.IsFalse(target.IsMatch("eggsa"));
            target = new Glob(@"eggs\\");
            Assert.IsTrue(target.IsMatch(@"eggs\"));
            Assert.IsFalse(target.IsMatch(@"eggsa"));
            target = new Glob(@"eggs\\?");
            Assert.IsTrue(target.IsMatch(@"eggs\a"));
            Assert.IsFalse(target.IsMatch(@"eggs\"));
            target = new Glob(@"eggs\\\?");
            Assert.IsTrue(target.IsMatch(@"eggs\?"));
            Assert.IsFalse(target.IsMatch(@"eggs\a"));
            target = new Glob(@"eggs\andham");
            Assert.IsTrue(target.IsMatch(@"eggs\andham"));
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.