当前位置: 首页>>代码示例>>C#>>正文


C# MockPackageRepository.AddRange方法代码示例

本文整理汇总了C#中MockPackageRepository.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# MockPackageRepository.AddRange方法的具体用法?C# MockPackageRepository.AddRange怎么用?C# MockPackageRepository.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MockPackageRepository的用法示例。


在下文中一共展示了MockPackageRepository.AddRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdatePackageUpdatesPackagesWithCommonDependency

        public void UpdatePackageUpdatesPackagesWithCommonDependency()
        {
            // Arrange
            var localRepository = new MockPackageRepository();
            var sourceRepository = new MockPackageRepository();
            var constraintProvider = NullConstraintProvider.Instance;
            var fileSystem = new MockFileSystem();
            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            var projectSystem = new MockProjectSystem();
            var packages = new List<IPackage>();

            var package_A10 = PackageUtility.CreatePackage("A", "1.0", content: new[] { "A.txt" }, dependencies: new[] { new PackageDependency("C", VersionUtility.ParseVersionSpec("1.0")) });
            var package_B10 = PackageUtility.CreatePackage("B", "1.0", content: new[] { "B.txt" }, dependencies: new[] { new PackageDependency("C", VersionUtility.ParseVersionSpec("1.0")) });
            var package_A12 = PackageUtility.CreatePackage("A", "1.2", content: new[] { "A.txt" }, dependencies: new[] { new PackageDependency("C", VersionUtility.ParseVersionSpec("1.0")) });
            var package_B20 = PackageUtility.CreatePackage("B", "2.0", content: new[] { "B.txt" });
            var package_C10 = PackageUtility.CreatePackage("C", "1.0", content: new[] { "C.txt" });
            localRepository.AddRange(new[] { package_A10, package_B10, package_C10});
            sourceRepository.AddRange(new[] { package_A12, package_B20 });

            var sharedRepository = new Mock<ISharedPackageRepository>(MockBehavior.Strict);
            sharedRepository.Setup(s => s.AddPackage(package_A12)).Callback<IPackage>(p => packages.Add(p)).Verifiable();
            sharedRepository.Setup(s => s.AddPackage(package_B20)).Callback<IPackage>(p => packages.Add(p)).Verifiable();
            sharedRepository.Setup(s => s.GetPackages()).Returns(packages.AsQueryable());
            var repositoryFactory = new Mock<IPackageRepositoryFactory>();
            repositoryFactory.Setup(s => s.CreateRepository(It.IsAny<string>())).Returns(sourceRepository);
            var packageSourceProvider = new Mock<IPackageSourceProvider>();
            packageSourceProvider.Setup(s => s.LoadPackageSources()).Returns(new[] { new PackageSource("foo-source") });

            var updateCommand = new UpdateCommand()
            {
                RepositoryFactory = repositoryFactory.Object,
                SourceProvider = packageSourceProvider.Object
            };

            // Act
            updateCommand.UpdatePackages(localRepository, fileSystem, sharedRepository.Object, sourceRepository, constraintProvider, pathResolver, projectSystem);

            // Assert
            sharedRepository.Verify();
        }
开发者ID:atheken,项目名称:nuget,代码行数:40,代码来源:UpdateCommandTest.cs

示例2: RecentPackageRepositoryDoesNotReturnPackagesFromSourcesThatAreDisabled

        public void RecentPackageRepositoryDoesNotReturnPackagesFromSourcesThatAreDisabled()
        {
            // Arrange
            var sources = new List<PackageSource> { new PackageSource("Source1"), new PackageSource("Source2", "Source2", isEnabled: false) };
            var factory = new Mock<IPackageRepositoryFactory>();
            factory.Setup(c => c.CreateRepository(It.IsAny<string>())).Returns<string>(c =>
            {
                switch (c)
                {
                    case "Source1":
                        var repo1 = new MockPackageRepository();
                        repo1.AddRange(new[] { PackageUtility.CreatePackage("Pack1") });
                        return repo1;
                    case "Source2":
                        var repo2 = new MockPackageRepository();
                        repo2.AddRange(new[] { PackageUtility.CreatePackage("Pack2", "1.1") });
                        return repo2;
                }
                return null;
            });

            var settingsManager = new MockSettingsManager();
            settingsManager.SavePackageMetadata(new[] {
                new PersistencePackageMetadata("Pack1", "1.0", new DateTime(2011, 01, 01)),
                new PersistencePackageMetadata("Pack2", "1.1", new DateTime(2011, 01, 01)),
                new PersistencePackageMetadata("Pack3", "1.0", new DateTime(2011, 01, 01)),
            });

            var sourceProvider = new Mock<IPackageSourceProvider>();
            sourceProvider.Setup(c => c.LoadPackageSources()).Returns(sources);
            var repository = new RecentPackageRepository(
                null,
                factory.Object,
                sourceProvider.Object,
                settingsManager,
                new MockPackageRepository());

            // Act
            var packages = repository.GetPackages();

            // Assert 
            Assert.Equal(1, packages.Count());
            AssertPackage(packages.First(), "Pack1", "1.0");
            //AssertPackage(packages.Last(), "Pack2", "1.1");
        }
开发者ID:monoman,项目名称:NugetCracker,代码行数:45,代码来源:RecentPackageRepositoryTest.cs

示例3: GetPackageRepository

 private static IPackageRepository GetPackageRepository(IEnumerable<IPackage> packages = null)
 {
     var repository = new MockPackageRepository();
     packages = packages ?? new[] { PackageUtility.CreatePackage("P1", "1.4"), PackageUtility.CreatePackage("P6") };
     repository.AddRange(packages);
     return repository;
 }
开发者ID:xero-github,项目名称:Nuget,代码行数:7,代码来源:FindPackageCommandTest.cs


注:本文中的MockPackageRepository.AddRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。