예제 #1
0
        public override IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            List <object[]> colorizeData = new List <object[]>();

            string appPath = Path.GetDirectoryName(new Uri(AssemblyShim.GetExecutingAssembly().CodeBase).LocalPath);

            string[] dirNames = Directory.GetDirectories(Path.Combine(appPath, @"Data"));

            foreach (string dirName in dirNames)
            {
                string[] sourceFileNames = Directory.GetFiles(dirName, "*.source.*");

                foreach (string sourceFileName in sourceFileNames)
                {
                    Match sourceFileMatch = sourceFileRegex.Match(sourceFileName);

                    if (sourceFileMatch.Success)
                    {
                        string fileExtension = sourceFileMatch.Groups[1].Captures[0].Value;
                        string languageId    = GetLanguageId(fileExtension);

                        string expectedFileName = sourceFileName.Replace(".source.", ".expected.").Replace("." + fileExtension, ".html");

                        colorizeData.Add(new object[] { languageId, sourceFileName, expectedFileName });
                    }
                }
            }

            return(colorizeData);
        }
        public void TransformWillStyleLargeHtmlIn1SecondOrLess()
        {
            string appPath = Path.GetDirectoryName(new Uri(AssemblyShim.GetExecutingAssembly().CodeBase).LocalPath);

            string source = File.ReadAllText(Path.Combine(appPath, @"LegacyAcceptanceTests\large.html"));

            Stopwatch sw = new Stopwatch();

            sw.Start();

            new CodeColorizer().Colorize(source, Languages.Html);

            sw.Stop();
            TimeSpan elapsed = sw.Elapsed;

            Console.WriteLine(elapsed.TotalSeconds);
            Assert.True(elapsed.TotalSeconds <= 1);
        }