本文整理汇总了C#中TestInstallCommand类的典型用法代码示例。如果您正苦于以下问题:C# TestInstallCommand类的具体用法?C# TestInstallCommand怎么用?C# TestInstallCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestInstallCommand类属于命名空间,在下文中一共展示了TestInstallCommand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InstallCommandUsesOutputDirectoryAsInstallPathIfSpecified
public void InstallCommandUsesOutputDirectoryAsInstallPathIfSpecified()
{
// Arrange
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider()) { OutputDirectory = @"Bar\Baz" };
// Act
string installPath = installCommand.ResolveInstallPath();
// Assert
Assert.Equal(@"Bar\Baz", installPath);
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:11,代码来源:InstallCommandTest.cs
示例2: InstallCommandUsesCurrentDirectoryAsInstallPathIfNothingSpecified
public void InstallCommandUsesCurrentDirectoryAsInstallPathIfNothingSpecified()
{
// Arrange
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider());
// Act
string installPath = installCommand.ResolveInstallPath();
// Assert
Assert.Equal(Directory.GetCurrentDirectory(), installPath);
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:11,代码来源:InstallCommandTest.cs
示例3: InstallCommandInstallsPackageIfArgumentIsNotPackageReferenceFile
public void InstallCommandInstallsPackageIfArgumentIsNotPackageReferenceFile()
{
// Arrange
var fileSystem = new MockFileSystem();
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem);
installCommand.Arguments.Add("Foo");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(@"Foo.1.0\Foo.1.0.nupkg", fileSystem.Paths.Single().Key);
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:13,代码来源:InstallCommandTest.cs
示例4: InstallCommandResolvesSourceName
public void InstallCommandResolvesSourceName()
{
// Arrange
var fileSystem = new MockFileSystem();
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem);
installCommand.Arguments.Add("Foo");
installCommand.Source.Add("Some source name");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(@"Foo.1.0\Foo.1.0.nupkg", fileSystem.Paths.Single().Key);
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:14,代码来源:InstallCommandTest.cs
示例5: InstallCommandForPackageReferenceFileDoesNotThrowIfThereIsNoPackageToInstall
public void InstallCommandForPackageReferenceFileDoesNotThrowIfThereIsNoPackageToInstall()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"x:\test\packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
</packages>".AsStream());
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem, allowPackageRestore: false);
installCommand.Arguments.Add(@"x:\test\packages.config");
// Act & Assert
installCommand.ExecuteCommand();
}
开发者ID:themotleyfool,项目名称:NuGet,代码行数:14,代码来源:InstallCommandTest.cs
示例6: InstallCommandInstallsPackageSuccessfullyIfCacheRepositoryIsNotSet
public void InstallCommandInstallsPackageSuccessfullyIfCacheRepositoryIsNotSet()
{
// Arrange
var fileSystem = new MockFileSystem();
var packageManager = new Mock<IPackageManager>(MockBehavior.Strict);
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem);
installCommand.Arguments.Add("Foo");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(@"Foo.1.0\Foo.1.0.nupkg", fileSystem.Paths.Single().Key);
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:14,代码来源:InstallCommandTest.cs
示例7: InstallCommandUsesInstallOperationIfArgumentIsNotPackageReferenceFile
public void InstallCommandUsesInstallOperationIfArgumentIsNotPackageReferenceFile()
{
// Arrange
var fileSystem = new MockFileSystem();
var mockRepo = new MockPackageRepository() { PackageUtility.CreatePackage("Foo") };
var mockFactory = new Mock<IPackageRepositoryFactory>();
mockFactory.Setup(r => r.CreateRepository(It.IsAny<string>())).Returns(mockRepo);
var installCommand = new TestInstallCommand(mockFactory.Object, GetSourceProvider(), fileSystem);
installCommand.Arguments.Add("Foo");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(RepositoryOperationNames.Install, mockRepo.LastOperation);
}
开发者ID:themotleyfool,项目名称:NuGet,代码行数:16,代码来源:InstallCommandTest.cs
示例8: InstallCommandForPackageReferenceFileThrowIfThereIsPackageToInstallAndConsentIsNotGranted
public void InstallCommandForPackageReferenceFileThrowIfThereIsPackageToInstallAndConsentIsNotGranted()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"x:\test\packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""Foo"" version=""1.0"" />
<package id=""Baz"" version=""0.7"" />
</packages>");
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem, allowPackageRestore: false);
installCommand.Arguments.Add(@"x:\test\packages.config");
// Act & Assert
Assert.Throws<InvalidOperationException>(() => installCommand.ExecuteCommand());
Assert.Equal(1, fileSystem.Paths.Count);
Assert.Equal(@"x:\test\packages.config", fileSystem.Paths.ElementAt(0).Key);
}
开发者ID:themotleyfool,项目名称:NuGet,代码行数:18,代码来源:InstallCommandTest.cs
示例9: InstallCommandInstallsAllPackagesFromConfigFileIfSpecifiedAsArgument
public void InstallCommandInstallsAllPackagesFromConfigFileIfSpecifiedAsArgument()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"dir\packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""Foo"" version=""1.0"" />
<package id=""Baz"" version=""0.7"" />
</packages>");
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem);
installCommand.Arguments.Add(@"dir\packages.config");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(3, fileSystem.Paths.Count);
Assert.Equal(@"dir\packages.config", fileSystem.Paths.ElementAt(0).Key);
Assert.Equal(@"Foo.1.0\Foo.1.0.nupkg", fileSystem.Paths.ElementAt(1).Key);
Assert.Equal(@"Baz.0.7\Baz.0.7.nupkg", fileSystem.Paths.ElementAt(2).Key);
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:21,代码来源:InstallCommandTest.cs
示例10: InstallCommandInstallsSatellitePackagesAfterCorePackages
public void InstallCommandInstallsSatellitePackagesAfterCorePackages()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"X:\test\packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""Foo.Fr"" version=""1.0.0"" />
<package id=""Foo"" version=""1.0.0"" />
</packages>");
var pathResolver = new DefaultPackagePathResolver(fileSystem);
var packageManager = new Mock<IPackageManager>(MockBehavior.Strict);
var package1 = PackageUtility.CreatePackage("Foo", "1.0.0");
var package2 = PackageUtility.CreatePackage("Foo.Fr", "1.0.0", language: "fr",
dependencies: new[] { new PackageDependency("Foo", VersionUtility.ParseVersionSpec("[1.0.0]")) });
var repository = new MockPackageRepository { package1, package2 };
// We *shouldn't* be testing if a sequence of operations worked rather that the outcome that satellite package was installed correctly,
// but doing so requires work with nice to have a unit test that tests it.
bool langPackInstalled = false;
packageManager.Setup(p => p.InstallPackage(package1, true, true, true)).Callback(() =>
{
if (langPackInstalled)
{
throw new Exception("Lang package installed first");
}
}).Verifiable();
packageManager.Setup(p => p.InstallPackage(package2, true, true)).Callback(() => langPackInstalled = true).Verifiable();
packageManager.SetupGet(p => p.PathResolver).Returns(pathResolver);
packageManager.SetupGet(p => p.LocalRepository).Returns(new LocalPackageRepository(pathResolver, fileSystem));
packageManager.SetupGet(p => p.FileSystem).Returns(fileSystem);
packageManager.SetupGet(p => p.SourceRepository).Returns(repository);
var repositoryFactory = new Mock<IPackageRepositoryFactory>();
repositoryFactory.Setup(r => r.CreateRepository("My Source")).Returns(repository);
var packageSourceProvider = Mock.Of<IPackageSourceProvider>();
// Act
var installCommand = new TestInstallCommand(repositoryFactory.Object, packageSourceProvider, fileSystem, packageManager.Object);
installCommand.Arguments.Add(@"X:\test\packages.config");
installCommand.ExecuteCommand();
// Assert
packageManager.Verify();
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:42,代码来源:InstallCommandTest.cs
示例11: InstallCommandInstallsPackageFromAllSourcesIfArgumentIsNotPackageReferenceFile
public void InstallCommandInstallsPackageFromAllSourcesIfArgumentIsNotPackageReferenceFile()
{
// Arrange
var fileSystem = new MockFileSystem();
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem);
installCommand.Arguments.Add("Foo");
// Act
installCommand.ExecuteCommand();
installCommand.Arguments.Clear();
installCommand.Arguments.Add("Bar");
installCommand.Version = "0.5";
installCommand.ExecuteCommand();
// Assert
Assert.Equal(@"Foo.1.0\Foo.1.0.nupkg", fileSystem.Paths.First().Key);
Assert.Equal(@"Bar.0.5\Bar.0.5.nupkg", fileSystem.Paths.Last().Key);
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:20,代码来源:InstallCommandTest.cs
示例12: InstallCommandFromConfigIgnoresDependencies
public void InstallCommandFromConfigIgnoresDependencies()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""Foo"" version=""1.0.0"" />
<package id=""Qux"" version=""2.3.56-beta"" />
</packages>");
var packageManager = new Mock<IPackageManager>(MockBehavior.Strict);
var package = PackageUtility.CreatePackage("Foo", "1.0.0");
packageManager.Setup(p => p.InstallPackage("Foo", new SemanticVersion("1.0.0"), true, true)).Verifiable();
packageManager.Setup(p => p.InstallPackage("Qux", new SemanticVersion("2.3.56-beta"), true, true)).Verifiable();
packageManager.SetupGet(p => p.PathResolver).Returns(new DefaultPackagePathResolver(fileSystem));
var repository = new MockPackageRepository();
var repositoryFactory = new Mock<IPackageRepositoryFactory>();
repositoryFactory.Setup(r => r.CreateRepository("My Source")).Returns(repository);
var packageSourceProvider = new Mock<IPackageSourceProvider>(MockBehavior.Strict);
// Act
var installCommand = new TestInstallCommand(repositoryFactory.Object, packageSourceProvider.Object, fileSystem, packageManager.Object);
installCommand.Arguments.Add("packages.config");
installCommand.Execute();
// Assert
packageManager.Verify();
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:28,代码来源:InstallCommandTest.cs
示例13: InstallCommandUsesLocalCacheIfNoCacheIsFalse
public void InstallCommandUsesLocalCacheIfNoCacheIsFalse()
{
// Arrange
var fileSystem = new MockFileSystem();
var localCache = new Mock<IPackageRepository>(MockBehavior.Strict);
localCache.Setup(c => c.GetPackages()).Returns(new[] { PackageUtility.CreatePackage("Gamma") }.AsQueryable()).Verifiable();
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem, machineCacheRepository: localCache.Object)
{
NoCache = false
};
installCommand.Arguments.Add("Gamma");
installCommand.Source.Add("Some Source name");
installCommand.Source.Add("Some other Source");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(@"Gamma.1.0\Gamma.1.0.nupkg", fileSystem.Paths.Single().Key);
localCache.Verify();
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:21,代码来源:InstallCommandTest.cs
示例14: InstallCommandUsesRestoreOperationIfArgumentIsPackageReferenceFile
public void InstallCommandUsesRestoreOperationIfArgumentIsPackageReferenceFile()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"x:\test\packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""Foo"" version=""1.0"" />
</packages>");
var mockRepo = new MockPackageRepository() { PackageUtility.CreatePackage("Foo") };
var mockFactory = new Mock<IPackageRepositoryFactory>();
mockFactory.Setup(r => r.CreateRepository(It.IsAny<string>())).Returns(mockRepo);
var installCommand = new TestInstallCommand(mockFactory.Object, GetSourceProvider(), fileSystem);
installCommand.Arguments.Add(@"x:\test\packages.config");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(RepositoryOperationNames.Restore, mockRepo.LastOperation);
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:20,代码来源:InstallCommandTest.cs
示例15: InstallCommandUpdatesPackagesFromPackagesConfigIfAlreadyPresentAndNotUsingSideBySide
public void InstallCommandUpdatesPackagesFromPackagesConfigIfAlreadyPresentAndNotUsingSideBySide()
{
// Arrange
var fileSystem = new MockFileSystem();
var packages = new List<IPackage> { PackageUtility.CreatePackage("Baz", "0.4") };
var repository = new Mock<IPackageRepository>();
repository.Setup(c => c.GetPackages()).Returns(packages.AsQueryable());
repository.Setup(c => c.AddPackage(It.IsAny<IPackage>())).Callback<IPackage>(c => packages.Add(c)).Verifiable();
repository.Setup(c => c.RemovePackage(It.IsAny<IPackage>())).Callback<IPackage>(c => packages.Remove(c)).Verifiable();
var packageManager = new PackageManager(GetFactory().CreateRepository("Some source"), new DefaultPackagePathResolver(fileSystem), fileSystem, repository.Object);
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem, packageManager);
installCommand.ExcludeVersion = true;
installCommand.Arguments.Add("Baz");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal("Baz", packages.Single().Id);
Assert.Equal(new SemanticVersion("0.7"), packages.Single().Version);
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:23,代码来源:InstallCommandTest.cs
示例16: InstallCommandUpdatesPackageFromPackagesConfigIfDifferentVersionAlreadyPresentAndNotUsingSideBySide
public void InstallCommandUpdatesPackageFromPackagesConfigIfDifferentVersionAlreadyPresentAndNotUsingSideBySide()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"baz\baz.0.4.nupkg");
var baz40 = PackageUtility.CreatePackage("Baz", "0.4");
var packages = new List<IPackage> { baz40 };
var repository = new Mock<LocalPackageRepository>(new DefaultPackagePathResolver(fileSystem, useSideBySidePaths: false), fileSystem) { CallBase = true };
repository.Setup(c => c.GetPackages()).Returns(packages.AsQueryable());
repository.Setup(c => c.Exists("Baz", new SemanticVersion("0.4"))).Returns(true);
repository.Setup(c => c.FindPackagesById("Baz")).Returns(packages);
repository.Setup(c => c.AddPackage(It.IsAny<IPackage>())).Callback<IPackage>(c => packages.Add(c)).Verifiable();
repository.Setup(c => c.RemovePackage(It.IsAny<IPackage>())).Callback<IPackage>(c => packages.Remove(c)).Verifiable();
var packageManager = new PackageManager(GetFactory().CreateRepository("Some source"), new DefaultPackagePathResolver(fileSystem), fileSystem, repository.Object);
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem, packageManager)
{
Console = new MockConsole()
};
installCommand.ExcludeVersion = true;
installCommand.Arguments.Add("Baz");
// Act
installCommand.ExecuteCommand();
// Assert
repository.Verify();
Assert.Equal("Baz", packages.Single().Id);
Assert.Equal(new SemanticVersion("0.7"), packages.Single().Version);
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:31,代码来源:InstallCommandTest.cs
示例17: InstallCommandNoOps_ExcludingVersionIsTrue_VersionIsEmpty_ExistingPackageIsNewerOrSame
public void InstallCommandNoOps_ExcludingVersionIsTrue_VersionIsEmpty_ExistingPackageIsNewerOrSame(
string installedVersion)
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"baz\baz.nupkg");
var baz = PackageUtility.CreatePackage("Baz", installedVersion);
var packages = new List<IPackage> { baz };
var repository = new Mock<LocalPackageRepository>(new DefaultPackagePathResolver(fileSystem, useSideBySidePaths: false), fileSystem) { CallBase = true };
repository.Setup(c => c.GetPackages()).Returns(packages.AsQueryable());
repository.Setup(c => c.Exists("Baz", new SemanticVersion(installedVersion))).Returns(true);
repository.Setup(c => c.FindPackagesById("Baz")).Returns(packages);
var packageManager = new PackageManager(GetFactory().CreateRepository("Some source"), new DefaultPackagePathResolver(fileSystem), fileSystem, repository.Object);
var console = new MockConsole();
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem, packageManager)
{
Console = console,
ExcludeVersion = true
};
installCommand.Arguments.Add("Baz");
// Act
installCommand.ExecuteCommand();
// Assert
repository.Verify();
Assert.Equal("Package \"Baz\" is already installed." + Environment.NewLine, console.Output);
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:30,代码来源:InstallCommandTest.cs
示例18: InstallCommandInstallsAllPackagesUsePackagesConfigByDefaultIfNoArgumentIsSpecified
public void InstallCommandInstallsAllPackagesUsePackagesConfigByDefaultIfNoArgumentIsSpecified()
{
// Arrange
var fileSystem = new MockFileSystem("x:\\test");
fileSystem.AddFile(@"packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""Foo"" version=""1.0"" />
<package id=""Baz"" version=""0.7"" />
</packages>");
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem);
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(3, fileSystem.Paths.Count);
Assert.Equal(@"packages.config", fileSystem.Paths.ElementAt(0).Key);
Assert.Contains(@"Foo.1.0\Foo.1.0.nupkg", fileSystem.Paths.Keys);
Assert.Contains(@"Baz.0.7\Baz.0.7.nupkg", fileSystem.Paths.Keys);
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:20,代码来源:InstallCommandTest.cs
示例19: InstallCommandUpdatesPackageIfAlreadyPresentAndNotUsingSideBySide
public void InstallCommandUpdatesPackageIfAlreadyPresentAndNotUsingSideBySide()
{
// Arrange
var fileSystem = new MockFileSystem();
var repository = new MockPackageRepository();
var packageManager = new PackageManager(GetFactory().CreateRepository("Some source"), new DefaultPackagePathResolver(fileSystem), fileSystem, repository);
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem, packageManager)
{
Console = new MockConsole(),
ExcludeVersion = true,
Version = "0.4",
};
installCommand.Arguments.Add("Baz");
// Act - 1
installCommand.ExecuteCommand();
// Assert - 1
Assert.True(repository.Exists("Baz", new SemanticVersion("0.4")));
// Act - 2
installCommand.Version = null;
installCommand.ExecuteCommand();
// Assert - 2
Assert.False(repository.Exists("Baz", new SemanticVersion("0.4")));
Assert.True(repository.Exists("Baz", new SemanticVersion("0.7")));
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:29,代码来源:InstallCommandTest.cs
示例20: InstallCommandDoesNotUseLocalCacheIfNoCacheIsTrue
public void InstallCommandDoesNotUseLocalCacheIfNoCacheIsTrue()
{
// Arrange
var fileSystem = new MockFileSystem();
var localCache = new Mock<IPackageRepository>(MockBehavior.Strict);
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider(), fileSystem, machineCacheRepository: localCache.Object)
{
NoCache = true
};
installCommand.Arguments.Add("Baz");
installCommand.Source.Add("Some Source name");
installCommand.Source.Add("Some other Source");
// Act
installCommand.ExecuteCommand();
// Assert
Assert.Equal(@"Baz.0.7\Baz.0.7.nupkg", fileSystem.Paths.Single().Key);
localCache.Verify(c => c.GetPackages(), Times.Never());
}
开发者ID:riteshparekh,项目名称:NuGet,代码行数:20,代码来源:InstallCommandTest.cs
注:本文中的TestInstallCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论