public void GetProjectReferenceAssemblyNames_for_websites_ignores_references_with_badly_formed_strong_names()
        {
            var project = MockDTE.CreateWebSite(
                new[]
            {
                // Deliberately emptying the PublicKeyToken causes a situation where
                // creating the AssemblyName throws. This test tests that the exception
                // is ignored and the other 2 references are still returned.
                // (See issue 1467).
                MockDTE.CreateAssemblyReference(
                    "AspNet.ScriptManager.jQuery.UI.Combined, Version=1.8.20.0, Culture=neutral, PublicKeyToken="),
                MockDTE.CreateAssemblyReference(
                    "System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
                MockDTE.CreateAssemblyReference(
                    "EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
            });

            var referenceAssemblyNames = VsUtils.GetProjectReferenceAssemblyNames(project).ToArray();

            Assert.Equal(2, referenceAssemblyNames.Count());
            Assert.Equal(
                0, referenceAssemblyNames.Where(
                    ran => ran.Key == "AspNet.ScriptManager.jQuery.UI.Combined").Count());
            Assert.Equal(
                1, referenceAssemblyNames.Where(
                    ran => ran.Key == "System.Data.Entity").Count());
            Assert.Equal(
                1, referenceAssemblyNames.Where(
                    ran => ran.Key == "EntityFramework").Count());
        }
        public void GetProjectTargetDir_returns_dir_when_website()
        {
            var project = MockDTE.CreateWebSite(
                properties: new Dictionary <string, object> {
                { "FullPath", @"C:\Path\To\WebSite" }
            });

            var targetDir = VsUtils.GetProjectTargetDir(project, Mock.Of <IServiceProvider>());

            Assert.Equal(@"C:\Path\To\WebSite\Bin\", targetDir);
        }
        public void GetProjectRoot_returns_fullpath_when_website()
        {
            const string fullPath = @"C:\Path\To\WebSite";
            var          project  = MockDTE.CreateWebSite(
                properties: new Dictionary <string, object> {
                { "FullPath", fullPath }
            });

            var root = VsUtils.GetProjectRoot(project, Mock.Of <IServiceProvider>());

            Assert.Equal(fullPath + Path.DirectorySeparatorChar, root.FullName);
        }
        public void AddProjectReference_adds_reference_for_websites()
        {
            var vsAssemblyReferences = new Mock <AssemblyReferences>();
            var vsWebSite            = new Mock <VSWebSite>();

            vsWebSite.SetupGet(p => p.References).Returns(vsAssemblyReferences.Object);
            var project = MockDTE.CreateWebSite();

            Mock.Get(project).Setup(p => p.Object).Returns(vsWebSite.Object);

            VsUtils.AddProjectReference(project, "System.Data");

            vsAssemblyReferences.Verify(r => r.AddFromGAC("System.Data"));
        }
        public void GetProjectReferenceAssemblyNames_handles_duplicate_references()
        {
            var project = MockDTE.CreateWebSite(
                new[]
            {
                MockDTE.CreateAssemblyReference(
                    "System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"),
                MockDTE.CreateAssemblyReference(
                    "System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35")
            });

            var referenceAssemblyNames = VsUtils.GetProjectReferenceAssemblyNames(project).ToArray();

            Assert.Equal(2, referenceAssemblyNames.Count());
            Assert.Equal("System.Web.WebPages.Deployment", referenceAssemblyNames.Last().Key);
            Assert.Equal(new Version(2, 0, 0, 0), referenceAssemblyNames.Last().Value);
        }
        public void GetProjectReferenceAssemblyNames_returns_references_for_websites()
        {
            var project = MockDTE.CreateWebSite(
                new[]
            {
                MockDTE.CreateAssemblyReference(
                    "System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
                MockDTE.CreateAssemblyReference(
                    "EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
            });

            var referenceAssemblyNames = VsUtils.GetProjectReferenceAssemblyNames(project).ToArray();

            Assert.Equal(2, referenceAssemblyNames.Count());
            Assert.Equal("EntityFramework", referenceAssemblyNames.Last().Key);
            Assert.Equal(new Version(5, 0, 0, 0), referenceAssemblyNames.Last().Value);
        }
Beispiel #7
0
        private static void Run_OnDeactivate_creates_and_verifies_model_path(
            ModelGenerationOption generationOption, LangEnum language, bool isWebSite, string expectedExtension)
        {
            var mockDte =
                new MockDTE(
                    ".NETFramework, Version=v4.5",
                    isWebSite
                        ? MockDTE.CreateWebSite(
                        properties: new Dictionary <string, object>
            {
                { "CurrentWebsiteLanguage", language == LangEnum.CSharp ? "C#" : "VB" }
            },
                        assemblyReferences: new AssemblyReference[0])
                        : MockDTE.CreateProject(
                        kind: language == LangEnum.CSharp ? MockDTE.CSharpProjectKind : MockDTE.VBProjectKind,
                        assemblyReferences: new Reference[0]));

            var modelBuilderSettings = new ModelBuilderSettings
            {
                NewItemFolder    = @"C:\temp",
                ModelName        = "myModel",
                Project          = mockDte.Project,
                GenerationOption = generationOption
            };

            var mockWizardPageStart =
                new Mock <WizardPageStart>(ModelBuilderWizardFormHelper.CreateWizard(modelBuilderSettings, mockDte.ServiceProvider), null)
            {
                CallBase = true
            };

            mockWizardPageStart
            .Protected()
            .Setup <bool>("VerifyModelFilePath", ItExpr.IsAny <string>())
            .Returns(false);

            mockWizardPageStart.Object.OnDeactivate();

            mockWizardPageStart
            .Protected()
            .Verify("VerifyModelFilePath", Times.Once(), @"C:\temp\myModel" + expectedExtension);
        }
        public void AssemblyLoader_passed_WebsiteProject_can_find_correct_paths_to_DLLs()
        {
            const string vsInstallPath = @"C:\My\Test\VS\InstallPath";
            const string projectPath   = @"C:\My\Test\WebsitePath";
            var          project       =
                MockDTE.CreateWebSite(
                    new[]
            {
                MockDTE.CreateAssemblyReference(
                    "EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
                    Path.Combine(projectPath, "EntityFramework.dll")),
                MockDTE.CreateAssemblyReference(
                    "EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
                    Path.Combine(projectPath, "EntityFramework.SqlServer.dll")),
                MockDTE.CreateAssemblyReference(
                    "EntityFramework.SqlServerCompact, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
                    Path.Combine(projectPath, "EntityFramework.SqlServerCompact.dll")),
                MockDTE.CreateAssemblyReference(
                    "My.WebsiteProject.Reference, Version=4.1.0.0, Culture=neutral, PublicKeyToken=bbbbbbbbbbbbbbbb",
                    Path.Combine(projectPath, "My.WebsiteProject.Reference.dll"))
            });
            var assemblyLoader = new DatabaseGenerationAssemblyLoader(project, vsInstallPath);

            // assert that the DLLs installed under VS are resolved there
            Assert.Equal(
                Path.Combine(vsInstallPath, "EntityFramework.dll"),
                assemblyLoader.GetAssemblyPath("EntityFramework"));
            Assert.Equal(
                Path.Combine(vsInstallPath, "EntityFramework.SqlServer.dll"),
                assemblyLoader.GetAssemblyPath("EntityFramework.SqlServer"));
            Assert.Equal(
                Path.Combine(vsInstallPath, "EntityFramework.SqlServerCompact.dll"),
                assemblyLoader.GetAssemblyPath("EntityFramework.SqlServerCompact"));

            // assert that other project references are resolved to wherever their reference points to
            Assert.Equal(
                Path.Combine(projectPath, "My.WebsiteProject.Reference.dll"),
                assemblyLoader.GetAssemblyPath("My.WebsiteProject.Reference"));
        }
 public void IsWebSiteProject_when_web()
 {
     Assert.True(VsUtils.IsWebSiteProject(MockDTE.CreateWebSite()));
 }
Beispiel #10
0
 public void GetProjectKind_when_web()
 {
     Assert.Equal(VsUtils.ProjectKind.Web, VsUtils.GetProjectKind(MockDTE.CreateWebSite()));
 }