当前位置: 首页>>代码示例>>C#>>正文


C# TestableVsTemplateWizard类代码示例

本文整理汇总了C#中TestableVsTemplateWizard的典型用法代码示例。如果您正苦于以下问题:C# TestableVsTemplateWizard类的具体用法?C# TestableVsTemplateWizard怎么用?C# TestableVsTemplateWizard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestableVsTemplateWizard类属于命名空间,在下文中一共展示了TestableVsTemplateWizard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunStartedForInvalidTemplateTypeHelper

        private static void RunStartedForInvalidTemplateTypeHelper(WizardRunKind runKind)
        {
            // Arrange
            var wizard = new TestableVsTemplateWizard();

            // Act
            ExceptionAssert.Throws<WizardBackoutException>(
                () => ((IWizard)wizard).RunStarted(null, null, runKind, null));

            // Assert
            Assert.Equal("This template wizard can only be applied to single-project or project-item templates.",
                wizard.ErrorMessages.Single());
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:13,代码来源:VsTemplateWizardTest.cs

示例2: AddNuGetPackageFolderTemplateParameterIsCorrectWhenProjectWebsiteIsHttpBased

        public void AddNuGetPackageFolderTemplateParameterIsCorrectWhenProjectWebsiteIsHttpBased(string directoryPath, string solutionPath, string expectedPath)
        {
            // Arrange
            var template = new TestableVsTemplateWizard();
            var parameters = new Dictionary<string, string>();

            parameters["$destinationdirectory$"] = directoryPath;
            parameters["$solutiondirectory$"] = solutionPath;

            // Act
            ((IVsTemplateWizard)template).RunStarted(new Mock<DTE>().Object, parameters, WizardRunKind.AsNewProject, new object[0]);

            string nugetFolder;
            bool result = parameters.TryGetValue("$nugetpackagesfolder$", out nugetFolder);

            // Assert
            Assert.True(result);
            Assert.Equal(expectedPath, nugetFolder);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:19,代码来源:VsTemplateWizardTest.cs

示例3: InvalidPackageElementHelper

        private static void InvalidPackageElementHelper(XElement[] content)
        {
            // Arrange
            var document = BuildDocument("template", content);
            var wizard = new TestableVsTemplateWizard();

            // Act
            // Use .ToList() to force enumeration of the yielded results
            ExceptionAssert.Throws<WizardBackoutException>(() => wizard.GetConfigurationsFromXmlDocument(document,
                @"C:\Some\file.vstemplate").ToList());

            // Assert
            Assert.Equal("The project template lists one or more packages with missing, empty, or invalid values for the \"id\" or \"version\" attributes. Both attributes are required and must have valid values.", wizard.ErrorMessages.Single());
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:14,代码来源:VsTemplateWizardTest.cs

示例4: GetConfigurationFromXmlDocument_ShowErrorForMissingRegistryValueWhenInRegistryRepositoryMode

        public void GetConfigurationFromXmlDocument_ShowErrorForMissingRegistryValueWhenInRegistryRepositoryMode()
        {
            // Arrange
            var registryPath = @"SOFTWARE\NuGet\Repository";
            var registryKey = "ThisRegistryKeyDoesNotExist";
            var document = BuildDocumentWithPackage("registry", new XAttribute("keyName", registryKey));
            var wizard = new TestableVsTemplateWizard();

            var hkcu_repository = new Mock<IRegistryKey>();
            var hkcu = new Mock<IRegistryKey>();
            hkcu_repository.Setup(k => k.GetValue(registryKey)).Returns(null);
            hkcu.Setup(r => r.OpenSubKey(registryPath)).Returns(hkcu_repository.Object);

            // Act
            // Use .ToList() to force enumeration of the yielded results
            ExceptionAssert.Throws<WizardBackoutException>(() =>
                                                           wizard.GetConfigurationsFromXmlDocument(document,
                                                               registryPath, registryKeys: new[] { hkcu.Object }).ToList());

            // Assert
            Assert.Equal(
                String.Format("The project template has a reference to a missing Registry value. Could not find a Registry key with name '{0}' under '{1}'.", registryKey, registryPath),
                wizard.ErrorMessages.Single());
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:24,代码来源:VsTemplateWizardTest.cs

示例5: GetConfigurationFromXmlDocument_ShowsErrorForInvalidCacheAttributeValue

        public void GetConfigurationFromXmlDocument_ShowsErrorForInvalidCacheAttributeValue()
        {
            // Arrange
            var document = BuildDocumentWithPackage("__invalid__");
            var wizard = new TestableVsTemplateWizard();

            // Act
            // Use .ToList() to force enumeration of the yielded results
            ExceptionAssert.Throws<WizardBackoutException>(() => wizard.GetConfigurationsFromXmlDocument(document,
                @"C:\Some\file.vstemplate").ToList());

            // Assert
            Assert.Equal(
                "The \"repository\" attribute of the package element has an invalid value: '__invalid__'. Valid values are: 'template' or 'extension'.",
                wizard.ErrorMessages.Single());
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:16,代码来源:VsTemplateWizardTest.cs

示例6: RunFinished_ForItem_InstallsPrereleasePackages

        public void RunFinished_ForItem_InstallsPrereleasePackages()
        {
            // Arrange
            var mockProject = new Mock<Project>().Object;
            var projectItemMock = new Mock<ProjectItem>();
            projectItemMock.Setup(i => i.ContainingProject).Returns(mockProject);
            var installerMock = new Mock<IVsPackageInstaller>();
            var document = BuildDocument("template",
                BuildPackageElement("MyPackage", "1.0.0-ctp-1"),
                BuildPackageElement("MyOtherPackage", "2.0.3.4"));
            var templateWizard = new TestableVsTemplateWizard(installerMock.Object, loadDocumentCallback: p => document);
            var wizard = (IWizard)templateWizard;
            var dteMock = new Mock<DTE>();
            dteMock.SetupProperty(dte => dte.StatusBar.Text);
            wizard.RunStarted(dteMock.Object, null, WizardRunKind.AsNewProject,
                new object[] { @"C:\Some\file.vstemplate" });
            wizard.ProjectItemFinishedGenerating(projectItemMock.Object);

            // Act
            wizard.RunFinished();

            // Assert
            installerMock.Verify(i => i.InstallPackage(It.Is<LocalPackageRepository>(p => p.Source == @"C:\Some"), mockProject, "MyPackage", "1.0.0-ctp-1", true, false));
            installerMock.Verify(i => i.InstallPackage(It.Is<LocalPackageRepository>(p => p.Source == @"C:\Some"), mockProject, "MyOtherPackage", "2.0.3.4", true, false));
            dteMock.VerifySet(dte => dte.StatusBar.Text = "Adding MyPackage.1.0.0-ctp-1 to project...");
            dteMock.VerifySet(dte => dte.StatusBar.Text = "Adding MyOtherPackage.2.0.3.4 to project...");
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:27,代码来源:VsTemplateWizardTest.cs

示例7: RunFinished_ForProject_InstallsDependenciesWhenIncludeDependenciesIsTrue

        public void RunFinished_ForProject_InstallsDependenciesWhenIncludeDependenciesIsTrue()
        {
            // Arrange
            var mockProject = new Mock<Project>().Object;
            var installerMock = new Mock<IVsPackageInstaller>();
            var document = BuildDocument("template",
                BuildPackageElement("MyPackage", "1.0", includeDependencies: true),
                BuildPackageElement("MyOtherPackage", "2.0"));

            var templateWizard = new TestableVsTemplateWizard(installerMock.Object, loadDocumentCallback: p => document);
            var wizard = (IWizard)templateWizard;
            var dteMock = new Mock<DTE>();
            dteMock.SetupProperty(dte => dte.StatusBar.Text);
            wizard.RunStarted(dteMock.Object, null, WizardRunKind.AsNewProject,
                new object[] { @"C:\Some\file.vstemplate" });
            wizard.ProjectFinishedGenerating(mockProject);

            // Act
            wizard.RunFinished();

            // Assert (the key here is that the ignoreDependencies parameter is false for MyPackage because we said to includeDependencies on that package element)
            installerMock.Verify(i => i.InstallPackage(It.Is<LocalPackageRepository>(p => p.Source == @"C:\Some"), mockProject, "MyPackage", "1.0", false, false));
            installerMock.Verify(i => i.InstallPackage(It.Is<LocalPackageRepository>(p => p.Source == @"C:\Some"), mockProject, "MyOtherPackage", "2.0", true, false));
            dteMock.VerifySet(dte => dte.StatusBar.Text = "Adding MyPackage.1.0 to project...");
            dteMock.VerifySet(dte => dte.StatusBar.Text = "Adding MyOtherPackage.2.0 to project...");
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:26,代码来源:VsTemplateWizardTest.cs

示例8: GetConfigurationFromXmlDocument_ShowErrorForMissingRepositoryIdAttributeWhenInExtensionRepositoryMode

        public void GetConfigurationFromXmlDocument_ShowErrorForMissingRepositoryIdAttributeWhenInExtensionRepositoryMode()
        {
            // Arrange
            var document = BuildDocumentWithPackage("extension");
            var wizard = new TestableVsTemplateWizard();

            // Act
            // Use .ToList() to force enumeration of the yielded results
            ExceptionAssert.Throws<WizardBackoutException>(() =>
                                                           wizard.GetConfigurationsFromXmlDocument(document,
                                                               @"C:\Some\file.vstemplate").ToList());

            // Assert
            Assert.Equal(
                "The project template is configured to use an Extension-specific package repository but the Extension ID has not been specified. Use the \"repositoryId\" attribute to specify the Extension ID.",
                wizard.ErrorMessages.Single());
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:17,代码来源:VsTemplateWizardTest.cs

示例9: GetConfigurationFromXmlDocument_ShowErrorForInvalidRepositoryIdAttributeWhenInExtensionRepositoryMode

        public void GetConfigurationFromXmlDocument_ShowErrorForInvalidRepositoryIdAttributeWhenInExtensionRepositoryMode()
        {
            // Arrange
            var document = BuildDocumentWithPackage("extension", new XAttribute("repositoryId", "myExtensionId"));
            var wizard = new TestableVsTemplateWizard();
            var extensionManagerMock = new Mock<IVsExtensionManager>();
            IInstalledExtension extension = null;
            extensionManagerMock.Setup(em => em.TryGetInstalledExtension("myExtensionId", out extension)).Returns(false);

            // Act
            // Use .ToList() to force enumeration of the yielded results
            ExceptionAssert.Throws<WizardBackoutException>(() => wizard.GetConfigurationsFromXmlDocument(document,
                @"C:\Some\file.vstemplate",
                vsExtensionManager: extensionManagerMock.Object).ToList());

            // Assert
            Assert.Equal(
                "The project template has a reference to a missing Extension. Could not find an Extension with ID 'myExtensionId'.",
                wizard.ErrorMessages.Single());
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:20,代码来源:VsTemplateWizardTest.cs

示例10: CopyNativeBinariesForWebsites

        public void CopyNativeBinariesForWebsites()
        {
            // Arrange
            var mockProject = new Mock<Project>();
            mockProject.Setup(s => s.Kind).Returns(VsConstants.WebSiteProjectTypeGuid);

            var installerMock = new Mock<IVsPackageInstaller>();
            var websiteHandler = new Mock<IVsWebsiteHandler>();
            websiteHandler.Setup(h =>
                h.CopyNativeBinaries(
                    mockProject.Object,
                    It.IsAny<IFileSystem>(),
                    It.Is<IEnumerable<PackageName>>(names => names.Count() == 2 && names.First().Id == "MyPackage" && names.Last().Id == "YourPackage")
                )).Verifiable();

            var document = BuildDocument("template",
                BuildPackageElement("MyPackage", "1.0", skipAssemblyReferences: true),
                BuildPackageElement("YourPackage", "3.0-alpha", skipAssemblyReferences: false));

            var repositorySettings = new Mock<IRepositorySettings>();
            repositorySettings.Setup(s => s.RepositoryPath).Returns("x:\\packages");

            var templateWizard = new TestableVsTemplateWizard(installerMock.Object, loadDocumentCallback: p => document, websiteHandler: websiteHandler.Object)
            {
                RepositorySettings = new Lazy<IRepositorySettings>(() => repositorySettings.Object)
            };
            var wizard = (IWizard)templateWizard;
            var dteMock = new Mock<DTE>();
            dteMock.SetupProperty(dte => dte.StatusBar.Text);
            wizard.RunStarted(dteMock.Object, null, WizardRunKind.AsNewProject,
                new object[] { @"C:\Some\file.vstemplate" });

            // Act
            wizard.ProjectFinishedGenerating(mockProject.Object);

            // Verify
            websiteHandler.Verify();
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:38,代码来源:VsTemplateWizardTest.cs

示例11: DoNotCopyNativeBinariesForNonWebsites

        public void DoNotCopyNativeBinariesForNonWebsites()
        {
            // Arrange
            var mockProject = new Mock<Project>();

            var installerMock = new Mock<IVsPackageInstaller>();
            var websiteHandler = new Mock<IVsWebsiteHandler>(MockBehavior.Strict);

            var document = BuildDocument("template",
                BuildPackageElement("MyPackage", "1.0", skipAssemblyReferences: true),
                BuildPackageElement("YourPackage", "3.0-alpha", skipAssemblyReferences: false));

            var repositorySettings = new Mock<IRepositorySettings>();
            repositorySettings.Setup(s => s.RepositoryPath).Returns("x:\\packages");

            var templateWizard = new TestableVsTemplateWizard(installerMock.Object, loadDocumentCallback: p => document, websiteHandler: websiteHandler.Object)
            {
                RepositorySettings = new Lazy<IRepositorySettings>(() => repositorySettings.Object)
            };
            var wizard = (IWizard)templateWizard;
            var dteMock = new Mock<DTE>();
            dteMock.SetupProperty(dte => dte.StatusBar.Text);
            wizard.RunStarted(dteMock.Object, null, WizardRunKind.AsNewProject,
                new object[] { @"C:\Some\file.vstemplate" });

            // Act
            wizard.ProjectFinishedGenerating(mockProject.Object);

            // Verify
            websiteHandler.Verify();
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:31,代码来源:VsTemplateWizardTest.cs

示例12: RunFinished_InstallsValidPackages_ReportsInstallationErrors

        public void RunFinished_InstallsValidPackages_ReportsInstallationErrors()
        {
            // Arrange
            var mockProject = new Mock<Project>().Object;
            var installerMock = new Mock<IVsPackageInstaller>();
            installerMock.Setup(i => i.InstallPackage(It.IsAny<IPackageRepository>(), mockProject, "MyPackage", "1.0", true, false))
                .Throws(new InvalidOperationException("But I don't want to be installed."));
            var document = BuildDocument("template",
                BuildPackageElement("MyPackage", "1.0"),
                BuildPackageElement("MyOtherPackage", "2.0"));
            var templateWizard = new TestableVsTemplateWizard(installerMock.Object,
                loadDocumentCallback: p => document);
            var wizard = (IWizard)templateWizard;
            var dteMock = new Mock<DTE>();
            dteMock.SetupProperty(dte => dte.StatusBar.Text);
            wizard.RunStarted(dteMock.Object, null, WizardRunKind.AsNewProject,
                new object[] { @"C:\Some\file.vstemplate" });
            wizard.ProjectFinishedGenerating(mockProject);

            // Act
            wizard.RunFinished();

            // Assert
            installerMock.Verify(
                i => i.InstallPackage(It.Is<LocalPackageRepository>(p => p.Source == @"C:\Some"), mockProject, "MyPackage", "1.0", true, false));
            installerMock.Verify(
                i => i.InstallPackage(It.Is<LocalPackageRepository>(p => p.Source == @"C:\Some"), mockProject, "MyOtherPackage", "2.0", true, false));
            dteMock.VerifySet(dte => dte.StatusBar.Text = "Adding MyPackage.1.0 to project...");
            dteMock.VerifySet(dte => dte.StatusBar.Text = "Adding MyOtherPackage.2.0 to project...");
            Assert.Equal(
                "Could not add all required packages to the project. The following packages failed to install from 'C:\\Some':\r\n\r\nMyPackage.1.0 : But I don't want to be installed.",
                templateWizard.ErrorMessages.Single());
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:33,代码来源:VsTemplateWizardTest.cs

示例13: InvalidPackageElementHelper

        private static void InvalidPackageElementHelper(XElement[] content)
        {
            // Arrange
            var document = BuildDocument("template", content);
            var wizard = new TestableVsTemplateWizard();

            // Act
            // Use .ToList() to force enumeration of the yielded results
            ExceptionAssert.Throws<WizardBackoutException>(() => wizard.GetConfigurationsFromXmlDocument(document,
                @"C:\Some\file.vstemplate").ToList());

            // Assert
            Assert.Equal(
                VsResources.TemplateWizard_InvalidPackageElementAttributes,
                wizard.ErrorMessages.Single());
        }
开发者ID:kumavis,项目名称:NuGet,代码行数:16,代码来源:VsTemplateWizardTest.cs

示例14: GetConfigurationFromXmlDocument_ShowErrorForMissingKeyNameAttributeWhenInRegistryRepositoryMode

        public void GetConfigurationFromXmlDocument_ShowErrorForMissingKeyNameAttributeWhenInRegistryRepositoryMode()
        {
            // Arrange
            var document = BuildDocumentWithPackage("registry");
            var wizard = new TestableVsTemplateWizard();

            // Act
            // Use .ToList() to force enumeration of the yielded results
            ExceptionAssert.Throws<WizardBackoutException>(() =>
                                                           wizard.GetConfigurationsFromXmlDocument(document,
                                                               @"C:\Some\file.vstemplate", registryKeys: Enumerable.Empty<IRegistryKey>()).ToList());

            // Assert
            Assert.Equal(
                VsResources.TemplateWizard_MissingRegistryKeyName,
                wizard.ErrorMessages.Single());
        }
开发者ID:kumavis,项目名称:NuGet,代码行数:17,代码来源:VsTemplateWizardTest.cs

示例15: RunStarted_LoadsConfigurationFromPath

        public void RunStarted_LoadsConfigurationFromPath()
        {
            // Arrange
            var document = new XDocument(new XElement("VSTemplate"));
            string path = null;
            var wizard = new TestableVsTemplateWizard(loadDocumentCallback: p =>
            {
                path = p;
                return document;
            });
            var dte = new Mock<DTE>().Object;

            // Act
            ((IWizard)wizard).RunStarted(dte, null, WizardRunKind.AsNewProject,
                new object[] { @"C:\SomePath\ToFile.vstemplate" });

            // Assert
            Assert.Equal(@"C:\SomePath\ToFile.vstemplate", path);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:19,代码来源:VsTemplateWizardTest.cs


注:本文中的TestableVsTemplateWizard类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。