private RecentPackageRepository CreateRecentPackageRepository(
            IEnumerable <IPackage> packagesList = null,
            IEnumerable <IPersistencePackageMetadata> settingsMetadata = null,
            IPackageRepository cacheRepository = null)
        {
            if (packagesList == null)
            {
                var packageA = PackageUtility.CreatePackage("A", "1.0");
                var packageC = PackageUtility.CreatePackage("C", "2.0");

                packagesList = new[] { packageA, packageC };
            }

            var mockRepository = new Mock <IPackageRepository>();

            mockRepository.Setup(p => p.GetPackages()).Returns(packagesList.AsQueryable());

            var mockRepositoryFactory = new Mock <IPackageRepositoryFactory>();

            mockRepositoryFactory.Setup(f => f.CreateRepository(It.IsAny <string>())).Returns(mockRepository.Object);

            var mockSettingsManager = new MockSettingsManager();

            if (settingsMetadata == null)
            {
                var A = new PersistencePackageMetadata("A", "1.0", new DateTime(2010, 8, 12));
                var B = new PersistencePackageMetadata("B", "2.0", new DateTime(2011, 3, 2));
                settingsMetadata = new[] { A, B };
            }

            mockSettingsManager.SavePackageMetadata(settingsMetadata);

            var mockPackageSourceProvider = new MockPackageSourceProvider();

            mockPackageSourceProvider.SavePackageSources(new[] { new PackageSource("source") });

            if (cacheRepository == null)
            {
                cacheRepository = new MockPackageRepository();
            }
            return(new RecentPackageRepository(
                       /* dte */ null,
                       mockRepositoryFactory.Object,
                       mockPackageSourceProvider,
                       mockSettingsManager,
                       cacheRepository));
        }
        private RecentPackagesRepository CreateRecentPackageRepository(IPackage[] packagesList = null, IPersistencePackageMetadata[] settingsMetadata = null)
        {
            if (packagesList == null)
            {
                var packageA = PackageUtility.CreatePackage("A", "1.0");
                var packageC = PackageUtility.CreatePackage("C", "2.0");

                packagesList = new[] { packageA, packageC };
            }

            var mockRepository = new Mock <IPackageRepository>();

            mockRepository.Setup(p => p.GetPackages()).Returns(packagesList.AsQueryable());

            var mockRepositoryFactory = new Mock <IPackageRepositoryFactory>();

            mockRepositoryFactory.Setup(f => f.CreateRepository(It.IsAny <PackageSource>())).Returns(mockRepository.Object);

            var mockSettingsManager = new MockSettingsManager();

            if (settingsMetadata == null)
            {
                var A = new PersistencePackageMetadata("A", "1.0", new DateTime(2010, 8, 12));
                var B = new PersistencePackageMetadata("B", "2.0", new DateTime(2011, 3, 2));
                settingsMetadata = new[] { A, B };
            }

            mockSettingsManager.SavePackageMetadata(settingsMetadata);

            var mockPackageSourceProvider = new Mock <IPackageSourceProvider>();

            mockPackageSourceProvider.Setup(p => p.AggregateSource).Returns(new PackageSource("All")
            {
                IsAggregate = true
            });

            return(new RecentPackagesRepository(null, mockRepositoryFactory.Object, mockPackageSourceProvider.Object, mockSettingsManager));
        }
        private RecentPackageRepository CreateRecentPackageRepository(
            IEnumerable<IPackage> packagesList = null,
            IEnumerable<IPersistencePackageMetadata> settingsMetadata = null,
            IPackageRepository cacheRepository = null)
        {
            if (packagesList == null)
            {
                var packageA = PackageUtility.CreatePackage("A", "1.0");
                var packageC = PackageUtility.CreatePackage("C", "2.0");

                packagesList = new[] { packageA, packageC };
            }

            var mockRepository = new Mock<IPackageRepository>();
            mockRepository.Setup(p => p.GetPackages()).Returns(packagesList.AsQueryable());

            var mockRepositoryFactory = new Mock<IPackageRepositoryFactory>();
            mockRepositoryFactory.Setup(f => f.CreateRepository(It.IsAny<string>())).Returns(mockRepository.Object);

            var mockSettingsManager = new MockSettingsManager();

            if (settingsMetadata == null)
            {
                var A = new PersistencePackageMetadata("A", "1.0", new DateTime(2010, 8, 12));
                var B = new PersistencePackageMetadata("B", "2.0", new DateTime(2011, 3, 2));
                settingsMetadata = new[] { A, B };
            }

            mockSettingsManager.SavePackageMetadata(settingsMetadata);

            var mockPackageSourceProvider = new MockPackageSourceProvider();
            mockPackageSourceProvider.SavePackageSources(new[] { new PackageSource("source") });

            if (cacheRepository == null)
            {
                cacheRepository = new MockPackageRepository();
            }
            return new RecentPackageRepository(
                /* dte */ null,
                mockRepositoryFactory.Object,
                mockPackageSourceProvider,
                mockSettingsManager,
                cacheRepository);
        }
        private RecentPackagesRepository CreateRecentPackageRepository(IPackage[] packagesList = null, IPersistencePackageMetadata[] settingsMetadata = null)
        {
            if (packagesList == null) {
                var packageA = PackageUtility.CreatePackage("A", "1.0");
                var packageC = PackageUtility.CreatePackage("C", "2.0");

                packagesList = new[] { packageA, packageC };
            }

            var mockRepository = new Mock<IPackageRepository>();
            mockRepository.Setup(p => p.GetPackages()).Returns(packagesList.AsQueryable());

            var mockRepositoryFactory = new Mock<IPackageRepositoryFactory>();
            mockRepositoryFactory.Setup(f => f.CreateRepository(It.IsAny<PackageSource>())).Returns(mockRepository.Object);

            var mockSettingsManager = new MockSettingsManager();

            if (settingsMetadata == null) {
                var A = new PersistencePackageMetadata("A", "1.0", new DateTime(2010, 8, 12));
                var B = new PersistencePackageMetadata("B", "2.0", new DateTime(2011, 3, 2));
                settingsMetadata = new[] { A, B };
            }

            mockSettingsManager.SavePackageMetadata(settingsMetadata);

            var mockPackageSourceProvider = new Mock<IPackageSourceProvider>();
            mockPackageSourceProvider.Setup(p => p.AggregateSource).Returns(new PackageSource("All") { IsAggregate = true });

            return new RecentPackagesRepository(null, mockRepositoryFactory.Object, mockPackageSourceProvider.Object, mockSettingsManager);
        }