public void TargetNetFrameworkVersion_returns_null_for_non_NetFramework_project()
        {
            var mockMonikerHelper = new MockDTE("Xbox,Version=v4.0");

            Assert.Null(
                NetFrameworkVersioningHelper.TargetNetFrameworkVersion(
                    mockMonikerHelper.Project, mockMonikerHelper.ServiceProvider));
        }
        public void TargetNetFrameworkVersion_returns_null_for_invalid_target_framework_moniker()
        {
            var mockMonikerHelper = new MockDTE("abc");

            Assert.Null(
                NetFrameworkVersioningHelper.TargetNetFrameworkVersion(
                    mockMonikerHelper.Project, mockMonikerHelper.ServiceProvider));
        }
        public void TargetNetFrameworkVersion_returns_null_for_non_string_target_net_framework_moniker()
        {
            var mockMonikerHelper = new MockDTE(new object());

            Assert.Null(
                NetFrameworkVersioningHelper.TargetNetFrameworkVersion(
                    mockMonikerHelper.Project, mockMonikerHelper.ServiceProvider));
        }
        public void TargetNetFrameworkVersion_returns_targeted_version_from_valid_net_framework_moniker()
        {
            var mockMonikerHelper = new MockDTE(".NETFramework,Version=v4.0,Profile=Client");

            Assert.Equal(
                NetFrameworkVersioningHelper.NetFrameworkVersion4,
                NetFrameworkVersioningHelper.TargetNetFrameworkVersion(
                    mockMonikerHelper.Project, mockMonikerHelper.ServiceProvider));
        }
        public void TargetNetFrameworkVersion_returns_null_for_misc_project()
        {
            const string vsMiscFilesProjectUniqueName = "<MiscFiles>";

            var mockMonikerHelper = new MockDTE("abc", vsMiscFilesProjectUniqueName);

            Assert.Null(
                NetFrameworkVersioningHelper.TargetNetFrameworkVersion(
                    mockMonikerHelper.Project, mockMonikerHelper.ServiceProvider));
        }
Esempio n. 6
0
        // <summary>
        //     Gets the target SCHEMA VERSION of the project's installed runtime, or if none,
        //     of the latest runtime available on the project's target framework.
        // </summary>
        public static Version GetEntityFrameworkVersion(Project project, IServiceProvider serviceProvider, bool useLatestIfNoEF = true)
        {
            Debug.Assert(project != null, "project != null");
            Debug.Assert(serviceProvider != null, "serviceProvider != null");

            if (VsUtils.IsMiscellaneousProject(project))
            {
                return(null);
            }

            var efAssemblyVersion   = VsUtils.GetInstalledEntityFrameworkAssemblyVersion(project);
            var netFrameworkVersion = NetFrameworkVersioningHelper.TargetNetFrameworkVersion(project, serviceProvider);

            if (efAssemblyVersion == null &&
                !useLatestIfNoEF)
            {
                return(RuntimeVersion.GetSchemaVersionForNetFrameworkVersion(netFrameworkVersion));
            }

            return(RuntimeVersion.GetTargetSchemaVersion(efAssemblyVersion, netFrameworkVersion));
        }