本文整理汇总了C#中MockPackageRepository类的典型用法代码示例。如果您正苦于以下问题:C# MockPackageRepository类的具体用法?C# MockPackageRepository怎么用?C# MockPackageRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockPackageRepository类属于命名空间,在下文中一共展示了MockPackageRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ResolveDependenciesForInstallPackageResolvesDependencyUsingDependencyProvider
public void ResolveDependenciesForInstallPackageResolvesDependencyUsingDependencyProvider()
{
// Arrange
IPackage packageA = PackageUtility.CreatePackage("A",
"1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B")
});
IPackage packageB = PackageUtility.CreatePackage("B");
var repository = new Mock<PackageRepositoryBase>();
repository.Setup(c => c.GetPackages()).Returns(new[] { packageA }.AsQueryable());
var dependencyProvider = repository.As<IDependencyResolver>();
dependencyProvider.Setup(c => c.ResolveDependency(It.Is<PackageDependency>(p => p.Id == "B"), It.IsAny<IPackageConstraintProvider>(), false, true, DependencyVersion.Lowest))
.Returns(packageB).Verifiable();
var localRepository = new MockPackageRepository();
IPackageOperationResolver resolver = new InstallWalker(localRepository,
repository.Object,
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false);
// Act
var operations = resolver.ResolveOperations(packageA).ToList();
// Assert
Assert.Equal(2, operations.Count);
Assert.Equal(PackageAction.Install, operations.First().Action);
Assert.Equal(packageB, operations.First().Package);
Assert.Equal(PackageAction.Install, operations.Last().Action);
Assert.Equal(packageA, operations.Last().Package);
dependencyProvider.Verify();
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:35,代码来源:PackageWalkerTest.cs
示例2: UninstallPackageDoesNotRemoveDependenciesIfFlagIsFalse
public void UninstallPackageDoesNotRemoveDependenciesIfFlagIsFalse()
{
// Arrange
var packageA = PackageUtility.CreatePackage(
"A", "1.0",
dependencies: new[] { new PackageDependency("B") });
var packageB = PackageUtility.CreatePackage("B", "1.0");
var packageRepository = new MockPackageRepository { packageA, packageB };
var packageManager = new MockVsPackageManager2(
@"c:\solution",
packageRepository);
InstallPackage("A", packageManager);
var installedPackages = packageManager.LocalRepository.GetPackages().ToList();
Assert.Equal(new[] { packageA, packageB }, installedPackages, PackageEqualityComparer.IdAndVersion);
var project = packageManager.SolutionManager.GetProject("default");
var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
packageManagerFactory.Setup(m => m.CreatePackageManager(It.IsAny<IPackageRepository>(), false)).Returns(packageManager);
var scriptExecutor = new Mock<IScriptExecutor>(MockBehavior.Strict);
scriptExecutor.Setup(s => s.Execute(@"c:\solution\A.1.0", "uninstall.ps1", packageA, project,
new FrameworkName(".NETFramework,Version=v4.0.0.0"), NullLogger.Instance)).Returns(true).Verifiable();
var packageUninstaller = new VsPackageUninstaller(
packageManagerFactory.Object,
packageManager.LocalRepository,
scriptExecutor.Object);
// Act
packageUninstaller.UninstallPackage(project, "A", removeDependencies: false);
// Assert: packageA is uninstalled, while packageB is not
scriptExecutor.Verify();
installedPackages = packageManager.LocalRepository.GetPackages().ToList();
Assert.Equal(new[] { packageB }, installedPackages, PackageEqualityComparer.IdAndVersion);
}
开发者ID:rikoe,项目名称:nuget,代码行数:35,代码来源:VsUninstallerTest.cs
示例3: ReverseDependencyWalkerUsersVersionAndIdToDetermineVisited
public void ReverseDependencyWalkerUsersVersionAndIdToDetermineVisited()
{
// Arrange
// A 1.0 -> B 1.0
IPackage packageA1 = PackageUtility.CreatePackage("A",
"1.0",
dependencies: new List<PackageDependency> {
PackageDependency.CreateDependency("B", "[1.0]")
});
// A 2.0 -> B 2.0
IPackage packageA2 = PackageUtility.CreatePackage("A",
"2.0",
dependencies: new List<PackageDependency> {
PackageDependency.CreateDependency("B", "[2.0]")
});
IPackage packageB1 = PackageUtility.CreatePackage("B", "1.0");
IPackage packageB2 = PackageUtility.CreatePackage("B", "2.0");
var mockRepository = new MockPackageRepository();
mockRepository.AddPackage(packageA1);
mockRepository.AddPackage(packageA2);
mockRepository.AddPackage(packageB1);
mockRepository.AddPackage(packageB2);
// Act
IDependentsResolver lookup = new DependentsWalker(mockRepository);
// Assert
Assert.Equal(0, lookup.GetDependents(packageA1).Count());
Assert.Equal(0, lookup.GetDependents(packageA2).Count());
Assert.Equal(1, lookup.GetDependents(packageB1).Count());
Assert.Equal(1, lookup.GetDependents(packageB2).Count());
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:34,代码来源:PackageWalkerTest.cs
示例4: ReinstallPackagesRestoresPackageWithTheSameVersion
public void ReinstallPackagesRestoresPackageWithTheSameVersion()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var projectManager = new ProjectManager(localRepository, pathResolver, projectSystem, new MockPackageRepository());
var packageManager = new VsPackageManager(
TestUtils.GetSolutionManager(),
sourceRepository,
new Mock<IFileSystemProvider>().Object,
projectSystem,
localRepository,
new Mock<IDeleteOnRestartManager>().Object,
new Mock<VsPackageInstallerEvents>().Object);
var packageA = PackageUtility.CreatePackage("A", "1.2", new[] { "content.txt" });
sourceRepository.Add(packageA);
localRepository.AddPackage(packageA);
projectManager.LocalRepository.AddPackage(packageA);
// Act
packageManager.ReinstallPackage(projectManager, "A", updateDependencies: true, allowPrereleaseVersions: true, logger: null);
// Assert
Assert.True(packageManager.LocalRepository.Exists("A", new SemanticVersion("1.2")));
Assert.True(projectManager.LocalRepository.Exists("A", new SemanticVersion("1.2")));
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:30,代码来源:VsPackageManagerTest.Reinstall.cs
示例5: GetPackagesWithPagingTakesLowestNElements
public void GetPackagesWithPagingTakesLowestNElements()
{
// Arrange
var r1 = new MockPackageRepository() {
PackageUtility.CreatePackage("A"),
PackageUtility.CreatePackage("B"),
PackageUtility.CreatePackage("E"),
};
var r2 = new MockPackageRepository() {
PackageUtility.CreatePackage("A"),
PackageUtility.CreatePackage("C"),
PackageUtility.CreatePackage("D"),
PackageUtility.CreatePackage("F"),
};
var repository = new AggregateRepository(new[] { r1, r2 });
// Act
var packages = repository.GetPackages().OrderBy(p => p.Id).Take(5).ToList();
// Assert
Assert.Equal(5, packages.Count);
Assert.Equal("A", packages[0].Id);
Assert.Equal("B", packages[1].Id);
Assert.Equal("C", packages[2].Id);
Assert.Equal("D", packages[3].Id);
Assert.Equal("E", packages[4].Id);
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:28,代码来源:AggregateRepositoryTest.cs
示例6: InstallPackageRunsInitAndInstallScripts
public void InstallPackageRunsInitAndInstallScripts()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
var sourceRepository = new MockPackageRepository();
var projectRepository = new MockProjectPackageRepository(localRepository);
var fileSystem = new MockFileSystem();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(new MockProjectSystem());
var project = TestUtils.GetProject("Foo");
var projectManager = new ProjectManager(localRepository, pathResolver, projectSystem, projectRepository);
var scriptExecutor = new Mock<IScriptExecutor>();
var packageManager = new Mock<VsPackageManager>(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, fileSystem, localRepository, new Mock<IRecentPackageRepository>().Object,
new Mock<VsPackageInstallerEvents>().Object) { CallBase = true };
var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
packageManagerFactory.Setup(m => m.CreatePackageManager(It.IsAny<IPackageRepository>(), false, false)).Returns(packageManager.Object);
packageManager.Setup(m => m.GetProjectManager(project)).Returns(projectManager);
var package = NuGet.Test.PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" }, tools: new[] { "init.ps1", "install.ps1" });
sourceRepository.AddPackage(package);
var installer = new VsPackageInstaller(packageManagerFactory.Object, scriptExecutor.Object, new Mock<IPackageRepositoryFactory>().Object, new Mock<IVsCommonOperations>().Object, new Mock<ISolutionManager>().Object);
// Act
installer.InstallPackage(sourceRepository, project, "foo", new SemanticVersion("1.0"), ignoreDependencies: false, skipAssemblyReferences: false);
// Assert
scriptExecutor.Verify(e => e.Execute(It.IsAny<string>(), PowerShellScripts.Init, It.IsAny<IPackage>(), It.IsAny<Project>(), It.IsAny<ILogger>()), Times.Once());
scriptExecutor.Verify(e => e.Execute(It.IsAny<string>(), PowerShellScripts.Install, It.IsAny<IPackage>(), It.IsAny<Project>(), It.IsAny<ILogger>()), Times.Once());
}
开发者ID:xero-github,项目名称:Nuget,代码行数:29,代码来源:VsInstallerTest.cs
示例7: UninstallPackageRemovesDependenciesIfFlagIsTrue
public void UninstallPackageRemovesDependenciesIfFlagIsTrue()
{
// Arrange
var activeRepository = new MockPackageRepository();
var localRepository = new Mock<MockPackageRepository>() { CallBase = true };
localRepository.As<ISharedPackageRepository>();
var projectRepository = new MockProjectPackageRepository(localRepository.Object);
var project = TestUtils.GetProject("Foo");
var projectSystem = new MockProjectSystem();
var projectManager = new ProjectManager(activeRepository, new DefaultPackagePathResolver(new MockFileSystem()), projectSystem, projectRepository);
var packageA = PackageUtility.CreatePackage("A", dependencies: new[] { new PackageDependency("B") });
var packageB = PackageUtility.CreatePackage("B");
var scriptExecutor = new Mock<IScriptExecutor>(MockBehavior.Strict);
scriptExecutor.Setup(s => s.Execute(@"C:\MockFileSystem\A.1.0", "uninstall.ps1", packageA, project, It.IsAny<FrameworkName>(), NullLogger.Instance)).Returns(true).Verifiable();
scriptExecutor.Setup(s => s.Execute(@"C:\MockFileSystem\B.1.0", "uninstall.ps1", packageB, project, It.IsAny<FrameworkName>(), NullLogger.Instance)).Returns(true).Verifiable();
var packageManager = new Mock<VsPackageManager>(TestUtils.GetSolutionManager(), activeRepository, new Mock<IFileSystemProvider>().Object, new MockFileSystem(), localRepository.Object,
new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object) { CallBase = true };
var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
packageManagerFactory.Setup(m => m.CreatePackageManager(activeRepository, false)).Returns(packageManager.Object);
packageManager.Setup(m => m.GetProjectManager(project)).Returns(projectManager).Verifiable();
var packageUninstaller = new VsPackageUninstaller(packageManagerFactory.Object, activeRepository, scriptExecutor.Object);
// Act
localRepository.Object.AddPackage(packageA);
localRepository.Object.AddPackage(packageB);
packageUninstaller.UninstallPackage(project, "A", removeDependencies: true);
// Assert
scriptExecutor.Verify();
Assert.False(localRepository.Object.Contains(packageA));
Assert.False(localRepository.Object.Contains(packageB));
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:33,代码来源:VsUninstallerTest.cs
示例8: AddPackageReferenceAppliesPackageReferencesCorrectly2
public void AddPackageReferenceAppliesPackageReferencesCorrectly2()
{
// Arrange
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem(new FrameworkName(".NETFramework, Version=4.5"));
var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());
IPackage packageA = PackageUtility.CreatePackage(
"A",
"1.0",
assemblyReferences: new[] { "lib\\net35\\a.dll", "lib\\net35\\b.dll" });
sourceRepository.AddPackage(packageA);
Mock<IPackage> mockPackageA = Mock.Get<IPackage>(packageA);
mockPackageA.Setup(m => m.PackageAssemblyReferences).Returns(
new PackageReferenceSet[] {
new PackageReferenceSet(VersionUtility.ParseFrameworkName("net40"), new [] { "a.dll" }),
new PackageReferenceSet(VersionUtility.ParseFrameworkName("net45"), new [] { "b.dll" })
}
);
// Act
projectManager.AddPackageReference("A");
// Assert
Assert.True(projectManager.LocalRepository.Exists("A"));
Assert.False(projectSystem.ReferenceExists("a.dll"));
Assert.True(projectSystem.ReferenceExists("b.dll"));
}
开发者ID:anurse,项目名称:NuGet,代码行数:28,代码来源:ProjectManagerTest.cs
示例9: UninstallPackageExecutesUninstallScript
public void UninstallPackageExecutesUninstallScript()
{
// Arrange
var activeRepository = new MockPackageRepository();
var localRepository = new Mock<MockPackageRepository>() { CallBase = true };
localRepository.As<ISharedPackageRepository>();
var projectRepository = new MockProjectPackageRepository(localRepository.Object);
var project = TestUtils.GetProject("Foo");
var projectSystem = new MockProjectSystem();
var projectManager = new ProjectManager(activeRepository, new DefaultPackagePathResolver(new MockFileSystem()), projectSystem, projectRepository);
var package = PackageUtility.CreatePackage("A");
var scriptExecutor = new Mock<IScriptExecutor>(MockBehavior.Strict);
scriptExecutor.Setup(s => s.Execute(@"C:\MockFileSystem\A.1.0", "uninstall.ps1", package, project, NullLogger.Instance)).Returns(true).Verifiable();
var packageManager = new Mock<VsPackageManager>(TestUtils.GetSolutionManager(), activeRepository, new MockFileSystem(), localRepository.Object,
new Mock<IRecentPackageRepository>().Object, new Mock<VsPackageInstallerEvents>().Object) { CallBase = true };
var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
packageManagerFactory.Setup(m => m.CreatePackageManager(activeRepository, false, false)).Returns(packageManager.Object);
packageManager.Setup(m => m.GetProjectManager(project)).Returns(projectManager).Verifiable();
var packageUninstaller = new VsPackageUninstaller(packageManagerFactory.Object, activeRepository, scriptExecutor.Object);
// Act
localRepository.Object.AddPackage(package);
packageUninstaller.UninstallPackage(project, "A", removeDependencies: true);
// Assert
scriptExecutor.Verify();
Assert.False(localRepository.Object.Contains(package));
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:29,代码来源:VsUninstallerTest.cs
示例10: AfterPackageWalkMetaPackageIsClassifiedTheSameAsDependencies
public void AfterPackageWalkMetaPackageIsClassifiedTheSameAsDependencies()
{
// Arrange
var mockRepository = new MockPackageRepository();
var walker = new TestWalker(mockRepository);
IPackage metaPackage = PackageUtility.CreatePackage("A", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B"),
new PackageDependency("C")
});
IPackage projectPackageA = PackageUtility.CreatePackage("B", "1.0", content: new[] { "contentB" });
IPackage projectPackageB = PackageUtility.CreatePackage("C", "1.0", content: new[] { "contentC" });
mockRepository.AddPackage(projectPackageA);
mockRepository.AddPackage(projectPackageB);
Assert.AreEqual(PackageTargets.None, walker.GetPackageInfo(metaPackage).Target);
// Act
walker.Walk(metaPackage);
// Assert
Assert.AreEqual(PackageTargets.Project, walker.GetPackageInfo(metaPackage).Target);
}
开发者ID:grendello,项目名称:nuget,代码行数:26,代码来源:PackageWalkerTest.cs
示例11: CreateMockRepository
public static MockPackageRepository CreateMockRepository()
{
var mockRepo = new MockPackageRepository();
mockRepo.AddPackage(PackageUtility.CreatePackage(PackageInRepository, isLatest: true, assemblyReferences: new List<string> { AssemblyFilenameInPackageRepository, "Assembly12.dll" }, dependencies: new List<PackageDependency>()));
mockRepo.AddPackage(PackageUtility.CreatePackage("Test2", isLatest: true, assemblyReferences: new List<string> { AnotherAssemblyInPackageRepository, "Assembly22.dll" }, dependencies: new List<PackageDependency> { new PackageDependency(PackageInRepository) }));
return mockRepo;
}
开发者ID:modulexcite,项目名称:NuGet.Extensions,代码行数:7,代码来源:ProjectReferenceTestData.cs
示例12: InstallPackageSetOperationToInstall3
public void InstallPackageSetOperationToInstall3()
{
// Arrange
var localRepository = new MockSharedPackageRepository();
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), new MockPackageRepository());
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, projectSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);
var package = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" });
sourceRepository.AddPackage(package);
var package2 = PackageUtility.CreatePackage("bar", "2.0", new[] { "world" });
sourceRepository.AddPackage(package2);
// Act
packageManager.InstallPackage(
projectManager,
package2,
new PackageOperation[] {
new PackageOperation(package, PackageAction.Install),
new PackageOperation(package2, PackageAction.Install),
},
ignoreDependencies: false,
allowPrereleaseVersions: false,
logger: NullLogger.Instance);
// Assert
Assert.Equal("Install", sourceRepository.LastOperation);
Assert.Equal("bar", sourceRepository.LastMainPackageId);
Assert.Equal("2.0", sourceRepository.LastMainPackageVersion);
}
开发者ID:Newtopian,项目名称:nuget,代码行数:33,代码来源:VsPackageManagerTest.Operation.cs
示例13: EnsurePackageDownloadsThePackageIfItIsNotCachedInMemoryOnInMachineCache
public void EnsurePackageDownloadsThePackageIfItIsNotCachedInMemoryOnInMachineCache()
{
// Arrange
var zipPackage = PackageUtility.CreatePackage("A", "1.2");
var uri = new Uri("http://nuget.org");
var packageDownloader = new Mock<PackageDownloader>();
packageDownloader.Setup(d => d.DownloadPackage(uri, It.IsAny<IPackageMetadata>()))
.Returns(zipPackage)
.Verifiable();
var hashProvider = new Mock<IHashProvider>(MockBehavior.Strict);
var mockRepository = new MockPackageRepository();
var context = new Mock<IDataServiceContext>();
context.Setup(c => c.GetReadStreamUri(It.IsAny<object>())).Returns(uri).Verifiable();
var servicePackage = new DataServicePackage
{
Id = "A",
Version = "1.2",
PackageHash = "NEWHASH",
Downloader = packageDownloader.Object,
HashProvider = hashProvider.Object,
Context = context.Object
};
// Act
servicePackage.EnsurePackage(mockRepository);
// Assert
context.Verify();
packageDownloader.Verify();
Assert.True(mockRepository.Exists(zipPackage));
}
开发者ID:xero-github,项目名称:Nuget,代码行数:32,代码来源:DataServicePackageTest.cs
示例14: IsReferencedReturnsTrueIfAnyOtherRepositoryReferencesAPackage
public void IsReferencedReturnsTrueIfAnyOtherRepositoryReferencesAPackage()
{
// Arrange
var fileSystem = new Mock<MockFileSystem>() { CallBase = true };
fileSystem.Setup(m => m.FileExists(@"A\packages.config")).Returns(true);
fileSystem.Setup(m => m.FileExists(@"..\..\packages.config")).Returns(true);
fileSystem.Object.AddFile("repositories.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<repositories>
<repository path=""A\packages.config"" />
<repository path=""..\..\packages.config"" />
<repository />
</repositories>");
fileSystem.Setup(m => m.Root).Returns(@"c:\foo\bar\baz");
var repository = new Mock<MockSharedRepository>(new DefaultPackagePathResolver(fileSystem.Object), fileSystem.Object) { CallBase = true };
var r1 = new MockPackageRepository {
PackageUtility.CreatePackage("A")
};
var r2 = new MockPackageRepository {
PackageUtility.CreatePackage("B")
};
repository.Setup(m => m.Create(@"A\packages.config")).Returns(r1);
repository.Setup(m => m.Create(@"..\..\packages.config")).Returns(r2);
// Act && Assert
Assert.IsTrue(repository.Object.IsReferenced("A", new Version("1.0")));
Assert.IsTrue(repository.Object.IsReferenced("B", new Version("1.0")));
Assert.IsFalse(repository.Object.IsReferenced("C", new Version("1.0")));
}
开发者ID:grendello,项目名称:nuget,代码行数:29,代码来源:SharedRepositoryTest.cs
示例15: AddPackageReferenceAddingPackageWithDuplicateReferenceOverwritesReference
public void AddPackageReferenceAddingPackageWithDuplicateReferenceOverwritesReference()
{
// Arrange
var projectSystem = new MockProjectSystem();
var localRepository = new MockPackageRepository();
var mockRepository = new MockPackageRepository();
var projectManager = new ProjectManager(mockRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, localRepository);
var packageA = PackageUtility.CreatePackage("A", "1.0",
assemblyReferences: new[] { "reference.dll" });
var packageB = PackageUtility.CreatePackage("B", "1.0",
assemblyReferences: new[] { "reference.dll" });
mockRepository.AddPackage(packageA);
mockRepository.AddPackage(packageB);
// Act
projectManager.AddPackageReference("A");
projectManager.AddPackageReference("B");
// Assert
Assert.AreEqual(0, projectSystem.Paths.Count);
Assert.AreEqual(1, projectSystem.References.Count);
Assert.IsTrue(projectSystem.References.ContainsKey(@"reference.dll"));
Assert.IsTrue(projectSystem.References.ContainsValue(@"B.1.0\reference.dll"));
Assert.IsTrue(localRepository.Exists("A"));
Assert.IsTrue(localRepository.Exists("B"));
}
开发者ID:larsw,项目名称:nuget,代码行数:27,代码来源:ProjectManagerTest.cs
示例16: GetPackagesReturnPrereleasePackages
public void GetPackagesReturnPrereleasePackages()
{
// Arrange
MockPackageRepository repository = new MockPackageRepository();
int numberOfPackages = 3;
IPackage[] packages = new IPackage[numberOfPackages];
for (int i = 0; i < numberOfPackages; i++)
{
packages[i] = PackageUtility.CreatePackage("A" + i, "1.0-alpha");
repository.AddPackage(packages[i]);
}
SimpleTreeNode node = CreateSimpleTreeNode(repository);
// Act
var producedPackages = node.GetPackages(allowPrereleaseVersions: true).ToList();
// Assert
Assert.Equal(packages.Length, producedPackages.Count);
for (int i = 0; i < numberOfPackages; i++)
{
Assert.Same(packages[i], producedPackages[i]);
}
}
开发者ID:xero-github,项目名称:Nuget,代码行数:26,代码来源:SimpleTreeNodeTest.cs
示例17: GetPackagesReturnsUpdatesWhenThereAreMultipleVersionsOfTheSamePackageId
public void GetPackagesReturnsUpdatesWhenThereAreMultipleVersionsOfTheSamePackageId()
{
// Arrange
var localRepository = new MockPackageRepository();
var sourceRepository = new MockServiceBasePackageRepository();
UpdatesTreeNode node = CreateUpdatesTreeNode(localRepository, sourceRepository, includePrerelease: false);
localRepository.AddPackage(PackageUtility.CreatePackage("A", "9.0-rtm"));
localRepository.AddPackage(PackageUtility.CreatePackage("B", "1.0"));
localRepository.AddPackage(PackageUtility.CreatePackage("A", "9.0"));
localRepository.AddPackage(PackageUtility.CreatePackage("A", "10.0"));
sourceRepository.AddPackage(PackageUtility.CreatePackage("A", "9.5"));
sourceRepository.AddPackage(PackageUtility.CreatePackage("B", "4.0-beta"));
sourceRepository.AddPackage(PackageUtility.CreatePackage("C", "1.2.3.4-alpha"));
// Act
var packages = node.GetPackages(searchTerm: null, allowPrereleaseVersions: true).ToList();
// Assert
Assert.Equal(2, packages.Count);
AssertPackage(packages[0], "A", "9.5");
AssertPackage(packages[1], "B", "4.0-beta");
}
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:25,代码来源:UpdatesTreeNodeTest.cs
示例18: InstallPackageCmdletPassesParametersCorrectlyWhenIdAndVersionAreSpecified
public void InstallPackageCmdletPassesParametersCorrectlyWhenIdAndVersionAreSpecified()
{
// Arrange
var packageA28 = PackageUtility.CreatePackage("A", "2.8");
var packageA31 = PackageUtility.CreatePackage("A", "3.1");
var packageRepository = new MockPackageRepository { packageA28, packageA31 };
var packageManager = new MockVsPackageManager2(
@"c:\solution",
packageRepository);
var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns(packageManager);
// Act
var cmdlet = new InstallPackageCommand(
packageManager.SolutionManager,
packageManagerFactory.Object,
null,
new Mock<IVsPackageSourceProvider>().Object,
null,
null,
new Mock<IVsCommonOperations>().Object,
new Mock<IDeleteOnRestartManager>().Object, true);
cmdlet.Id = "A";
cmdlet.Version = new SemanticVersion("2.8");
cmdlet.Execute();
// Assert: version 2.8 is installed.
var installedPackages = packageManager.LocalRepository.GetPackages().ToList();
Assert.Equal(1, installedPackages.Count);
Assert.Equal(packageA28, installedPackages[0], PackageEqualityComparer.IdAndVersion);
}
开发者ID:rikoe,项目名称:nuget,代码行数:31,代码来源:InstallPackageCommandTest.cs
示例19: AddPackageReferenceWhenNewVersionOfPackageAlreadyReferencedThrows
public void AddPackageReferenceWhenNewVersionOfPackageAlreadyReferencedThrows()
{
// Arrange
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());
IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B")
}, content: new[] { "foo" });
IPackage packageA20 = PackageUtility.CreatePackage("A", "2.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B")
}, content: new[] { "foo" });
IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0", content: new[] { "foo" });
projectManager.LocalRepository.AddPackage(packageA20);
projectManager.LocalRepository.AddPackage(packageB10);
sourceRepository.AddPackage(packageA20);
sourceRepository.AddPackage(packageB10);
sourceRepository.AddPackage(packageA10);
sourceRepository.AddPackage(packageA20);
sourceRepository.AddPackage(packageB10);
// Act & Assert
ExceptionAssert.Throws<InvalidOperationException>(() => projectManager.AddPackageReference("A", SemanticVersion.Parse("1.0")), @"Already referencing a newer version of 'A'.");
}
开发者ID:themotleyfool,项目名称:NuGet,代码行数:27,代码来源:ProjectManagerTest.cs
示例20: XdtTransformOnXmlNodeWithAttributes
public void XdtTransformOnXmlNodeWithAttributes()
{
// Arrange
var mockProjectSystem = new MockProjectSystem();
var mockRepository = new MockPackageRepository();
mockProjectSystem.AddFile("test.xml",
@"<a attrib=""b""/>".AsStream());
var projectManager = new ProjectManager(mockRepository, new DefaultPackagePathResolver(new MockProjectSystem()), mockProjectSystem, new MockPackageRepository());
var package = new Mock<IPackage>();
package.Setup(m => m.Id).Returns("A");
package.Setup(m => m.Version).Returns(new SemanticVersion("1.0"));
package.Setup(m => m.Listed).Returns(true);
var file = new Mock<IPackageFile>();
file.Setup(m => m.Path).Returns(@"content\test.xml.install.xdt");
file.Setup(m => m.EffectivePath).Returns("test.xml.install.xdt");
file.Setup(m => m.GetStream()).Returns(() =>
@"<a xmlns:xdt=""http://schemas.microsoft.com/XML-Document-Transform""><test xdt:Transform=""InsertIfMissing""/></a>".AsStream());
package.Setup(m => m.GetFiles()).Returns(new[] { file.Object });
mockRepository.AddPackage(package.Object);
// Act
projectManager.AddPackageReference("A");
// Assert
Assert.True(mockProjectSystem.FileExists("test.xml"));
var actual = mockProjectSystem.OpenFile("test.xml").ReadToEnd();
Assert.Equal("<a attrib=\"b\">\t<test/></a>", actual);
}
开发者ID:Newtopian,项目名称:nuget,代码行数:31,代码来源:XdtTransformTest.cs
注:本文中的MockPackageRepository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论