예제 #1
0
        /// <summary>
        /// Any files that are needed for linking should come from the expectations assembly so that these values
        /// can be controlled using #ifs regardless of the framework the NUnit test project is compiled against
        /// </summary>
        /// <param name="metadataProvider"></param>
        public virtual void PopulateFromExpectations(TestCaseMetadataProvider metadataProvider)
        {
            foreach (var res in metadataProvider.GetResponseFiles())
            {
                res.Source.FileMustExist().Copy(InputDirectory.Combine(res.DestinationFileName));
            }

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

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

            foreach (var res in metadataProvider.GetLinkAttributesFiles())
            {
                res.Source.FileMustExist().Copy(InputDirectory.Combine(res.DestinationFileName));
            }
        }
예제 #2
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)));
                }
            }

            // 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 res in metadataProvider.GetResponseFiles())
            {
                res.Source.FileMustExist().Copy(InputDirectory.Combine(res.DestinationFileName));
            }

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

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

            foreach (var res in metadataProvider.GetLinkAttributesFiles())
            {
                res.Source.FileMustExist().Copy(InputDirectory.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));
                }
            }
        }