Esempio n. 1
0
        /// <summary>
        /// Returns metric info created from given test.
        /// </summary>
        /// <param name="test">Test which source will be used for metric info generating.</param>
        /// <returns>Generated metric info.</returns>
        internal static MetricInfo GetInfo(SourceTest test)
        {
            var uid        = GetTestFileUID();
            var fileName   = string.Format(CultureInfo.InvariantCulture, "./test{0}.php", uid);
            var sourceFile = new PhpSourceFile(new FullPath(Path.GetDirectoryName(fileName)),
                                               new FullPath(fileName));

            using (var parser = new SyntaxParser(sourceFile, "<?php " + test.SourceCode + " ?>"))
            {
                return(MetricInfo.FromParsers(true, parser));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Test given source according to predicate. On fail throws assertion error with testDescription.
        /// </summary>
        /// <param name="predicate"></param>
        /// <param name="test"></param>
        internal static void RunTest(MetricPredicate predicate, SourceTest test)
        {
            var metricInfo = GetInfo(test);

            Assert.IsTrue(predicate(metricInfo), test.Description);
        }