Пример #1
0
        public void TestDate()
        {
            //String to test
            array[0] = "Posted: Sat, 25 Aug 2012 18:36:26 -0400";
            // Method call
            List<List<StringAndColor>> test = TextProcessor.ParseInput("Neil", array);

            // Array created from scratch to test output
            List<List<StringAndColor>> expected = new List<List<StringAndColor>>();
            List<StringAndColor> coloredText = new List<StringAndColor>();

            coloredText.Add(new StringAndColor("Posted: Sat, ", "default"));
            coloredText.Add(new StringAndColor("25 Aug 2012", "red"));
            coloredText.Add(new StringAndColor(" 18:36:26 -0400", "default"));
            expected.Add(coloredText);

            // Unboxing, sadly we found no other way of doing this
            StringAndColor[] a1 = new StringAndColor[3];
            StringAndColor[] a2 = new StringAndColor[3];
            int count = 0;
            foreach (List<StringAndColor> l in test)
                foreach (StringAndColor s in l)
                {
                    a1[count] = s;
                    count++;
                }

            count = 0;

            foreach (List<StringAndColor> l in expected)
                foreach (StringAndColor s in l)
                {
                    a2[count] = s;
                    count++;
                }

            for (int i = 0; i < a1.Length; i++)
            {
                Assert.AreEqual(true, a1[i].Text.Equals(a2[i].Text));
                Assert.AreEqual(true, a1[i].Color.Equals(a2[i].Color));
            }
        }
Пример #2
0
        public void TestTwoStrings()
        {
            //String to test
            array[0] = "Neil Armstrong walked on";
            // Method call
            List<List<StringAndColor>> test = TextProcessor.ParseInput("Armstrong+walked", array);

            // Array created from scratch to test output
            List<List<StringAndColor>> expected = new List<List<StringAndColor>>();
            List<StringAndColor> coloredText = new List<StringAndColor>();

            coloredText.Add(new StringAndColor("Neil ", "default"));
            coloredText.Add(new StringAndColor("Armstrong walked", "yellow"));
            coloredText.Add(new StringAndColor(" on", "default"));
            expected.Add(coloredText);

            // Unboxing, sadly we found no other way of doing this
            StringAndColor[] a1 = new StringAndColor[3];
            StringAndColor[] a2 = new StringAndColor[3];
            int count = 0;
            foreach (List<StringAndColor> l in test)
                foreach (StringAndColor s in l)
                {
                    a1[count] = s;
                    count++;
                }

            count = 0;

            foreach (List<StringAndColor> l in expected)
                foreach (StringAndColor s in l)
                {
                    a2[count] = s;
                    count++;
                }

            for (int i = 0; i < a1.Length; i++)
            {
                Assert.AreEqual(true, a1[i].Text.Equals(a2[i].Text));
                Assert.AreEqual(true, a1[i].Color.Equals(a2[i].Color));
            }
        }
Пример #3
0
        public void TestLink()
        {
            //String to test
            array[0] = "http://feeds.reuters.com/~r/reuters/topNews/~3/ptoAzETqy3w/us-usa-neilarmstrong-idUSBRE87O0B020120825";
            // Method call
            List<List<StringAndColor>> test = TextProcessor.ParseInput("Neil", array);

            // Array created from scratch to test output
            List<List<StringAndColor>> expected = new List<List<StringAndColor>>();
            List<StringAndColor> coloredText = new List<StringAndColor>();

            coloredText.Add(new StringAndColor("http://feeds.reuters.com/~r/reuters/topNews/~3/ptoAzETqy3w/us-usa-neilarmstrong-idUSBRE87O0B020120825", "blue"));
            expected.Add(coloredText);

            // Unboxing, sadly we found no other way of doing this
            StringAndColor[] a1 = new StringAndColor[1];
            StringAndColor[] a2 = new StringAndColor[1];
            int count = 0;
            foreach (List<StringAndColor> l in test)
                foreach (StringAndColor s in l)
                {
                    a1[count] = s;
                    count++;
                }

            count = 0;

            foreach (List<StringAndColor> l in expected)
                foreach (StringAndColor s in l)
                {
                    a2[count] = s;
                    count++;
                }

            for (int i = 0; i < a1.Length; i++)
            {
                Assert.AreEqual(true, a1[i].Text.Equals(a2[i].Text));
                Assert.AreEqual(true, a1[i].Color.Equals(a2[i].Color));
            }
        }