Exemplo n.º 1
0
        private static NetPortableProfileCollection BuildPortableProfileCollection()
        {
            var profileCollection = new NetPortableProfileCollection();

            var referenceAssembliesPath = FrameworkReferenceResolver.GetReferenceAssembliesPath();

            if (!string.IsNullOrEmpty(referenceAssembliesPath))
            {
                string portableRootDirectory = Path.Combine(referenceAssembliesPath, ".NETPortable");

                if (Directory.Exists(portableRootDirectory))
                {
                    foreach (string versionDir in Directory.EnumerateDirectories(portableRootDirectory, "v*", SearchOption.TopDirectoryOnly))
                    {
                        string profileFilesPath = Path.Combine(versionDir, "Profile");
                        foreach (var profile in LoadProfilesFromFramework(versionDir, profileFilesPath))
                        {
                            profileCollection.Add(profile);
                        }
                    }
                }
            }

            return(profileCollection);
        }
        public void FrameworkResolverResolvesCorrectPaths(string shortFrameworkName, string assemblyName, string expectedPath, string expectedVersion)
        {
            var resolver = new FrameworkReferenceResolver();

            string  actualPath;
            Version actualVersion;
            var     result = resolver.TryGetAssembly(assemblyName, VersionUtility.ParseFrameworkName(shortFrameworkName), out actualPath, out actualVersion);

            if (string.IsNullOrEmpty(expectedPath))
            {
                Assert.False(result);
            }
            else
            {
                Assert.True(result);
                Assert.Equal(Environment.ExpandEnvironmentVariables(expectedPath).Replace("REFASMSROOT", FrameworkReferenceResolver.GetReferenceAssembliesPath()), actualPath);
                // Having this be Version->Version equality caused some problems...
                Assert.Equal(Version.Parse(expectedVersion).ToString(), actualVersion.ToString());
            }
        }
        public void FrameworkResolverReturnsCorrectAttemptedPaths(string shortFrameworkName, string attemptedPaths)
        {
            var resolver = new FrameworkReferenceResolver();
            var paths    = resolver.GetAttemptedPaths(VersionUtility.ParseFrameworkName(shortFrameworkName));

            Assert.Equal(
                attemptedPaths.Split(',').Select(s => Environment.ExpandEnvironmentVariables(s).Replace("REFASMSROOT", FrameworkReferenceResolver.GetReferenceAssembliesPath())).ToArray(),
                paths.ToArray());
        }