本文整理汇总了C#中TestInstallCommand.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# TestInstallCommand.Execute方法的具体用法?C# TestInstallCommand.Execute怎么用?C# TestInstallCommand.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestInstallCommand
的用法示例。
在下文中一共展示了TestInstallCommand.Execute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallCommandUpdatesPackageIfAlreadyPresentAndNotUsingSideBySide
public void InstallCommandUpdatesPackageIfAlreadyPresentAndNotUsingSideBySide()
{
// Arrange
var fileSystem = new MockFileSystem();
var packages = new List<IPackage>();
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.Version = "0.4";
installCommand.ExcludeVersion = true;
installCommand.Arguments.Add("Baz");
// Act - 1
installCommand.ExecuteCommand();
// Assert - 1
Assert.Equal("Baz", packages.Single().Id);
Assert.Equal(new SemanticVersion("0.4"), packages.Single().Version);
// Act - 2
installCommand.Version = null;
installCommand.Execute();
// Assert - 2
Assert.Equal("Baz", packages.Single().Id);
Assert.Equal(new SemanticVersion("0.7"), packages.Single().Version);
repository.Verify();
}
示例2: 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();
}
示例3: InstallCommandFromConfigPerformsQuickCheckForFiles
public void InstallCommandFromConfigPerformsQuickCheckForFiles()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"X:\test\packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""Foo"" version=""1.8.0"" />
<package id=""Qux"" version=""2.3.56-beta"" />
</packages>");
fileSystem.AddFile("Foo.1.8.nupkg");
var pathResolver = new DefaultPackagePathResolver(fileSystem);
var packageManager = new Mock<IPackageManager>(MockBehavior.Strict);
var repository = new MockPackageRepository();
packageManager.Setup(p => p.InstallPackage("Qux", new SemanticVersion("2.3.56-beta"), true, 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 = new Mock<IPackageSourceProvider>(MockBehavior.Strict);
// Act
var installCommand = new TestInstallCommand(repositoryFactory.Object, packageSourceProvider.Object, fileSystem, packageManager.Object)
{
Console = new MockConsole()
};
installCommand.Arguments.Add(@"X:\test\packages.config");
installCommand.Execute();
// Assert
packageManager.Verify();
}