Exemplo n.º 1
0
        public virtual void Populate(TestCaseMetadaProvider metadataProvider)
        {
            _testCase.SourceFile.Copy(_directory);

            if (_testCase.HasLinkXmlFile)
            {
                _testCase.LinkXmlFile.Copy(InputDirectory);
            }

            CopyToInputAndExpectations(GetExpectationsAssemblyPath());

            foreach (var dep in metadataProvider.AdditionalFilesToSandbox())
            {
                var destination = _directory.Combine(dep.DestinationFileName);
                dep.Source.FileMustExist().Copy(destination);

                // In a few niche tests we need to copy pre-built assemblies directly into the input directory.
                // When this is done, we also need to copy them into the expectations directory so that if they are used
                // as references we can still compile the expectations version of the assemblies
                if (destination.Parent == InputDirectory)
                {
                    dep.Source.Copy(ExpectationsDirectory.Combine(destination.RelativeTo(InputDirectory)));
                }
            }

            foreach (var res in metadataProvider.GetResources())
            {
                res.Source.FileMustExist().Copy(ResourcesDirectory.Combine(res.DestinationFileName));
            }

            foreach (var compileRefInfo in metadataProvider.GetSetupCompileAssembliesBefore())
            {
                var destination = BeforeReferenceSourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();
                compileRefInfo.SourceFiles.Copy(destination);

                destination = BeforeReferenceResourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();
                compileRefInfo.Resources?.Copy(destination);
            }

            foreach (var compileRefInfo in metadataProvider.GetSetupCompileAssembliesAfter())
            {
                var destination = AfterReferenceSourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();
                compileRefInfo.SourceFiles.Copy(destination);

                destination = AfterReferenceResourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();
                compileRefInfo.Resources?.Copy(destination);
            }
        }
Exemplo n.º 2
0
        public virtual void Populate(TestCaseCompilationMetadataProvider metadataProvider)
        {
            _testCase.SourceFile.Copy(_directory);

            if (_testCase.HasLinkXmlFile)
            {
                _testCase.LinkXmlFile.Copy(InputDirectory);
            }

            CopyToInputAndExpectations(GetExpectationsAssemblyPath());

            foreach (var dep in metadataProvider.AdditionalFilesToSandbox())
            {
                var destination = _directory.Combine(dep.DestinationFileName);
                dep.Source.FileMustExist().Copy(destination);

                // In a few niche tests we need to copy pre-built assemblies directly into the input directory.
                // When this is done, we also need to copy them into the expectations directory so that if they are used
                // as references we can still compile the expectations version of the assemblies
                if (destination.Parent == InputDirectory)
                {
                    dep.Source.Copy(ExpectationsDirectory.Combine(destination.RelativeTo(InputDirectory)));
                }
            }

            // Copy non class library dependencies to the sandbox
            foreach (var fileName in metadataProvider.GetReferenceValues())
            {
                if (!fileName.StartsWith("System.", StringComparison.Ordinal) && !fileName.StartsWith("Mono.", StringComparison.Ordinal) && !fileName.StartsWith("Microsoft.", StringComparison.Ordinal))
                {
                    CopyToInputAndExpectations(_testCase.SourceFile.Parent.Combine(fileName.ToNPath()));
                }
            }

            foreach (var referenceDependency in metadataProvider.GetReferenceDependencies())
            {
                CopyToInputAndExpectations(_testCase.SourceFile.Parent.Combine(referenceDependency.ToNPath()));
            }

            foreach (var res in metadataProvider.GetResources())
            {
                res.Source.FileMustExist().Copy(ResourcesDirectory.Combine(res.DestinationFileName));
            }

            foreach (var compileRefInfo in metadataProvider.GetSetupCompileAssembliesBefore())
            {
                var destination = BeforeReferenceSourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();
                compileRefInfo.SourceFiles.Copy(destination);

                destination = BeforeReferenceResourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();

                if (compileRefInfo.Resources == null)
                {
                    continue;
                }

                foreach (var res in compileRefInfo.Resources)
                {
                    res.Source.FileMustExist().Copy(destination.Combine(res.DestinationFileName));
                }
            }

            foreach (var compileRefInfo in metadataProvider.GetSetupCompileAssembliesAfter())
            {
                var destination = AfterReferenceSourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();
                compileRefInfo.SourceFiles.Copy(destination);

                destination = AfterReferenceResourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();

                if (compileRefInfo.Resources == null)
                {
                    continue;
                }

                foreach (var res in compileRefInfo.Resources)
                {
                    res.Source.FileMustExist().Copy(destination.Combine(res.DestinationFileName));
                }
            }
        }