本文整理汇总了C#中Settings.IsSourceControlDisabled方法的典型用法代码示例。如果您正苦于以下问题:C# Settings.IsSourceControlDisabled方法的具体用法?C# Settings.IsSourceControlDisabled怎么用?C# Settings.IsSourceControlDisabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings.IsSourceControlDisabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallingEnableCurrentSolutionDownloadPrereleasePackagesButDoNotUnlistedPackage
public void CallingEnableCurrentSolutionDownloadPrereleasePackagesButDoNotUnlistedPackage()
{
// Arrange
string tempSolutionPath = CreateTempFolder();
// setup SolutionManager
var solutionManager = new Mock<ISolutionManager>();
solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);
// setup file system
var fileSystem = new PhysicalFileSystem(tempSolutionPath);
var fileSystemProvider = new Mock<IFileSystemProvider>();
fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);
var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");
fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);
// default app settings
var defaultAppSettings = new Mock<ISettings>();
defaultAppSettings.Setup(s => s.GetValue("packageRestore", "enabled")).Returns("false");
// setup DTE
var dte = new Mock<DTE>();
var projectItems = new Mock<ProjectItems>();
var solutionFolder = new Mock<Project>();
solutionFolder.Setup(s => s.Name).Returns(".nuget");
solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);
var solution = new Mock<Solution>();
solution.As<Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);
var projects = new MockProjects(new Project[0]);
solution.As<Solution2>().Setup(s => s.Projects).Returns(projects);
dte.SetupGet(p => p.Solution).Returns(solution.Object);
// setup package repository
var packageRepository = new MockPackageRepository();
packageRepository.Add(PackageUtility.CreatePackage(
"NuGet.Build",
version: "1.0",
tools: new string[] { "NuGet.targets" },
dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") }));
// this package contains 'invalid.targets' in the tools folder.
// it shouldn't be installed because it is unlisted.
packageRepository.Add(PackageUtility.CreatePackage(
"NuGet.Build",
version: "2.0",
tools: new string[] { "invalid.targets" },
dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") },
listed: false));
// this verify that we accepts prerelease packages
packageRepository.Add(PackageUtility.CreatePackage(
"NuGet.CommandLine",
version: "1.0-alpha",
tools: new string[] { "NuGet.exe" }));
var packageRepositoryFactory = new Mock<IPackageRepositoryFactory>();
packageRepositoryFactory.Setup(p => p.CreateRepository(NuGetConstants.DefaultFeedUrl)).Returns(packageRepository);
var packageSourceProvider = new Mock<IPackageSourceProvider>();
packageSourceProvider.Setup(p => p.LoadPackageSources()).Returns(new[]
{
new PackageSource(NuGetConstants.DefaultFeedUrl)
});
var packageRestore = CreateInstance(
dte.Object,
solutionManager.Object,
fileSystemProvider.Object,
packageRepositoryFactory.Object,
packageSourceProvider: packageSourceProvider.Object,
settings: defaultAppSettings.Object);
// Act
packageRestore.EnableCurrentSolutionForRestore(fromActivation: false);
// Assert
// verify that the files are copied to the .nuget sub folder under solution
Assert.True(Directory.Exists(Path.Combine(tempSolutionPath, ".nuget")));
Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.exe")));
Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.targets")));
// verify that solution folder 'nuget' is added to solution
solution.As<Solution2>().Verify(p => p.AddSolutionFolder(".nuget"));
projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.exe"));
projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.targets"));
// verify that the Source Control mode is disabled
var settings = new Settings(nugetFolderFileSystem);
Assert.True(settings.IsSourceControlDisabled());
// verify that package restore consent is not set
defaultAppSettings.Verify(
s => s.SetValue("packageRestore", "enabled", It.Is<string>(v => v == "true" || v == "1")), Times.Never());
}
示例2: CallingEnableCurrentSolutionSetupEverythingCorrectly
public void CallingEnableCurrentSolutionSetupEverythingCorrectly()
{
// Arrange
string tempSolutionPath = CreateTempFolder();
// setup SolutionManager
var solutionManager = new Mock<ISolutionManager>();
solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);
// setup file system
var fileSystem = new PhysicalFileSystem(tempSolutionPath);
var fileSystemProvider = new Mock<IFileSystemProvider>();
fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);
var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");
fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);
// setup DTE
var dte = new Mock<DTE>();
var projectItems = new Mock<ProjectItems>();
var solutionFolder = new Mock<Project>();
solutionFolder.Setup(s => s.Name).Returns(".nuget");
solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);
var solution = new Mock<Solution>();
solution.As<Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);
var projects = new MockProjects(new Project[0]);
solution.As<Solution2>().Setup(s => s.Projects).Returns(projects);
dte.SetupGet(p => p.Solution).Returns(solution.Object);
// setup package repository
var packageRepository = new MockPackageRepository();
packageRepository.Add(PackageUtility.CreatePackage(
"NuGet.Build",
version: "1.0",
tools: new string[] { "NuGet.targets" },
dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") }));
packageRepository.Add(PackageUtility.CreatePackage(
"NuGet.CommandLine",
version: "1.0",
tools: new string[] { "NuGet.exe" }));
var packageRepositoryFactory = new Mock<IPackageRepositoryFactory>();
packageRepositoryFactory.Setup(p => p.CreateRepository(NuGetConstants.DefaultFeedUrl)).Returns(packageRepository);
var packageRestore = CreateInstance(
dte.Object,
solutionManager.Object,
fileSystemProvider.Object,
packageRepositoryFactory.Object);
// Act
packageRestore.EnableCurrentSolutionForRestore(quietMode: true);
// Assert
// verify that the files are copied to the .nuget sub folder under solution
Assert.True(Directory.Exists(Path.Combine(tempSolutionPath, ".nuget")));
Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.exe")));
Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.targets")));
// verify that solution folder 'nuget' is added to solution
solution.As<Solution2>().Verify(p => p.AddSolutionFolder(".nuget"));
projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.exe"));
projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.targets"));
// verify that the Source Control mode is disabled
var settings = new Settings(nugetFolderFileSystem);
Assert.True(settings.IsSourceControlDisabled());
// clean up
Directory.Delete(tempSolutionPath, recursive: true);
}