Example #1
0
        public void RunAssembly(Assembly assembly)
        {
            var contexts = _explorer.FindContextsIn(assembly);
            var map      = CreateMap(assembly, contexts);

            StartRun(map);
        }
Example #2
0
        public string DiscoverSpecs(Assembly assembly)
        {
            var contextListElement = new XElement("contexts");

            contextListElement.Add(new XAttribute("version", Version));

            var contexts = explorer.FindContextsIn(assembly);

            foreach (var context in contexts)
            {
                var contextInfoElement = context.GetInfo().ToXml();

                var specificationsListElement = new XElement("specifications");

                foreach (var spec in context.Specifications)
                {
                    specificationsListElement.Add(spec.GetInfo().ToXml());
                }

                contextInfoElement.Add(specificationsListElement);
                contextListElement.Add(contextInfoElement);
            }

            return(contextListElement.ToString());
        }
        public IEnumerable <MSpecTestCase> DiscoverTests(string assemblyPath)
        {
            AssemblyExplorer assemblyExplorer = new AssemblyExplorer();

            Assembly assembly = Assembly.LoadFile(assemblyPath);
            IEnumerable <Context> contexts = assemblyExplorer.FindContextsIn(assembly);

            return(contexts.SelectMany(context => CreateTestCase(context, assemblyPath)).ToList());
        }
Example #4
0
        public IEnumerable <MSpecTestCase> DiscoverTests(string assemblyPath)
        {
            AssemblyExplorer assemblyExplorer = new AssemblyExplorer();

            Assembly assembly = AssemblyHelper.Load(assemblyPath);
            IEnumerable <Context> contexts = assemblyExplorer.FindContextsIn(assembly);

            SourceCodeLocationFinder locationFinder = new SourceCodeLocationFinder(assemblyPath);

            return(contexts.SelectMany(context => CreateTestCase(context, locationFinder)).ToList());
        }
        Test GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, bool populateRecursively)
        {
            MachineAssemblyTest assemblyTest;

            if (!assemblyTests.TryGetValue(assembly, out assemblyTest))
            {
                assemblyTest      = new MachineAssemblyTest(assembly.Name, assembly, frameworkVersion);
                assemblyTest.Kind = TestKinds.Assembly;

                ModelUtils.PopulateMetadataFromAssembly(assembly, assemblyTest.Metadata);

                string frameworkName = String.Format("Machine Specifications v{0}", frameworkVersion);
                assemblyTest.Metadata.SetValue(MetadataKeys.Framework, frameworkName);
                assemblyTest.Metadata.SetValue(MetadataKeys.File, assembly.Path);
                assemblyTest.Kind = TestKinds.Assembly;

                parentTest.AddChild(assemblyTest);
                assemblyTests.Add(assembly, assemblyTest);
            }

            if (populateRecursively)
            {
                AssemblyExplorer explorer         = new AssemblyExplorer();
                Assembly         resolvedAssembly = assembly.Resolve(false);

                assemblyTest.AssemblyContexts         = explorer.FindAssemblyContextsIn(resolvedAssembly).ToList();
                assemblyTest.GlobalCleanup            = explorer.FindAssemblyWideContextCleanupsIn(resolvedAssembly).ToList();
                assemblyTest.SpecificationSupplements = explorer.FindSpecificationSupplementsIn(resolvedAssembly).ToList();

                explorer.FindContextsIn(resolvedAssembly)
                .Select(context => GetContextTest(context))
                .Each(test => assemblyTest.AddChild(test));
            }

            return(assemblyTest);
        }