コード例 #1
0
        public IEnumerable <KeyValuePair <string, bool?> > ExecuteAllTests(ExecutionEnvironment environment, IPackage package)
        {
            var descriptor = new PackageDescriptor();

            descriptor.Dependencies.Add(new PackageDependencyBuilder(Guid.NewGuid().ToString()).Name(package.Name).VersionVertex(new EqualVersionVertex(package.Version)));

            var allAssemblyReferences = _manager.GetProjectAssemblyReferences(descriptor, package.Source, environment, false);

            var runners = _factories.SelectMany(x => x.GetTestRunners(allAssemblyReferences)).NotNull();

            var tests = new DefaultAssemblyExporter("tests").Items <Exports.IAssembly>(package, environment);

            if (tests == null)
            {
                return(Enumerable.Empty <KeyValuePair <string, bool?> >());
            }

            var testAssemblies = from item in tests.SelectMany(x => x)
                                 where item.File.Extension.Equals(".dll")
                                 select item.File.Path.FullPath;

            return(from runner in runners
                   from asm in testAssemblies
                   from result in runner.ExecuteTests(allAssemblyReferences.Select(x => x.File.Path.FullPath).ToList(), testAssemblies)
                   select result);
        }
コード例 #2
0
        protected override void GetMetadata(string path, string repository, out PackageProject project, out IList <MetadataEntry> metadata, out ILookup <ContentType, string> contents)
        {
            var assemblyExporter = new DefaultAssemblyExporter();
            var packageInfo      = new FolderRepository(LocalFileSystem.Instance.GetDirectory(path)).PackagesByName.Single().Single();
            var package          = packageInfo.Load();
            var descriptor       = package.Descriptor;

            var exports = assemblyExporter
                          .Items <Exports.IAssembly>(package, ExecutionEnvironment.Any)
                          .SelectMany(group => group)
                          .GroupBy(assembly => new { assembly.Profile, assembly.Platform });

            project =
                new PackageProject
            {
                Name       = descriptor.Name,
                Repository = repository,
                Version    =
                    new PackageVersion
                {
                    Name         = descriptor.Version.ToString(),
                    Compilations = exports
                                   .Select(group =>
                                           new PackageCompilation
                    {
                        Mode       = "Release",
                        Platform   = group.Key.Profile + "-" + group.Key.Platform,
                        ImageFiles = group
                                     .Select(assembly =>
                                             new PackageImageFile
                        {
                            Name = GetAssemblyPath(assembly.File.Path, path)
                        }).ToArray(),
                    }).ToArray(),
                },
            };

            using (var zip = new ZipFile(GetFilePath(path)))
                contents = zip.EntryFileNames.ToLookup(GetContentType);

            metadata = new List <MetadataEntry>();
        }