本文整理汇总了C#中TestInstallCommand类的典型用法代码示例。如果您正苦于以下问题:C# TestInstallCommand类的具体用法?C# TestInstallCommand怎么用?C# TestInstallCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestInstallCommand类属于命名空间,在下文中一共展示了TestInstallCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: InstallCommandUsesCurrentDirectoryAsInstallPathIfNothingSpecified
public void InstallCommandUsesCurrentDirectoryAsInstallPathIfNothingSpecified()
{
// Arrange
var installCommand = new TestInstallCommand(GetFactory(), GetSourceProvider());
// Act
string installPath = installCommand.ResolveInstallPath();
// Assert
Assert.Equal(Directory.GetCurrentDirectory(), installPath);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}