Beispiel #1
0
        public void TestCacheBuildEmptyLocalRepository() {
            var cache = new RepositoryCache();
            var localRepository = new MockPackageRepository();

            cache.Build(localRepository);

            Assert.IsEmpty(cache.Repositories.SelectMany(repository => repository.Packages));
        }
Beispiel #2
0
        public void TestExceptionOnCacheBuildAttachedToRepositoryModel() {
            var cache = new RepositoryCache();
            var localRepository = new MockPackageRepository();

            cache.Add("localhost");

            cache.SourceRepositories.TryAdd("localhost", new MockExceptionPackageRepository());

            // Now successfully build the repository..
            cache.Build(localRepository);

            Assert.AreEqual("GetPackages Exception", cache.Repositories.First(repository => repository.IsOrphanage == false).CacheError);
        }
Beispiel #3
0
        public void TestCacheBuildOrphanedLocalRepository() {
            var cache = new RepositoryCache();
            var localRepository = new MockPackageRepository(
                new List<IPackage>() {
                    new DataServicePackage() {
                        Id = "A",
                        Version = "1.0.0",
                        Tags = "Procon Potato Tag2"
                    }
                }
            );

            cache.Build(localRepository);

            Assert.IsNotEmpty(cache.Repositories.First(repository => repository.IsOrphanage == true).Packages);
            Assert.AreEqual("A", cache.Repositories.First(repository => repository.IsOrphanage == true).Packages.First().Id);
            Assert.AreEqual(PackageState.Installed, cache.Repositories.First(repository => repository.IsOrphanage == true).Packages.First().State);
        }
        public void TestResultAlreadyExists() {
            var cache = new RepositoryCache();
            var localRepository = new MockPackageRepository();

            cache.Add("localhost");

            cache.SourceRepositories.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "1.0.0",
                    Tags = "Procon Potato Tag2",
                    IsLatestVersion = true
                }
            }));

            cache.Build(localRepository);

            PackagesController packages = new PackagesController() {
                Cache = cache
            };

            ICommandResult result = packages.Tunnel(CommandBuilder.PackagesUninstallPackage("A").SetOrigin(CommandOrigin.Local));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.AlreadyExists, result.CommandResultType);
        }
Beispiel #5
0
        public void TestLastCacheBuildErrorNulled() {
            var cache = new RepositoryCache();
            var localRepository = new MockPackageRepository();

            cache.Add("localhost");

            cache.SourceRepositories.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "1.0.0",
                    Tags = "Procon Potato Tag2",
                    IsLatestVersion = true
                }
            }));

            cache.Repositories.First(repository => repository.IsOrphanage == false).CacheError = "Error!!";

            // Now successfully build the repository..
            cache.Build(localRepository);

            Assert.IsNull(cache.Repositories.First(repository => repository.IsOrphanage == false).CacheError);
        }
Beispiel #6
0
        public void TestCacheBuildSingleRemoteRepositoryUpdateAvailableLocalRepository() {
            var cache = new RepositoryCache();
            var localRepository = new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "1.0.0",
                    Tags = "Procon Potato Tag2"
                }
            });

            cache.Add("localhost");

            cache.SourceRepositories.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "2.0.0",
                    Tags = "Procon Potato Tag2",
                    IsLatestVersion = true
                }
            }));

            cache.Build(localRepository);

            Assert.IsNotEmpty(cache.Repositories.SelectMany(repository => repository.Packages));
            Assert.AreEqual("A", cache.Repositories.SelectMany(repository => repository.Packages).First().Id);
            Assert.AreEqual(PackageState.UpdateAvailable, cache.Repositories.SelectMany(repository => repository.Packages).First().State);
        }
Beispiel #7
0
        public void TestIgnoreMissingPotatoTag() {
            var cache = new RepositoryCache();
            var localRepository = new MockPackageRepository();

            cache.Add("localhost");

            cache.SourceRepositories.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "1.0.0",
                    Tags = "Tag1 Tag2",
                    IsLatestVersion = true
                },
                new DataServicePackage() {
                    Id = "B",
                    Version = "1.0.0",
                    Tags = "Procon Potato Tag2",
                    IsLatestVersion = true
                },
                new DataServicePackage() {
                    Id = "C",
                    Version = "1.0.0",
                    Tags = "Tag1 Tag2",
                    IsLatestVersion = true
                }
            }));

            cache.Build(localRepository);

            Assert.AreEqual(1, cache.Repositories.SelectMany(repository => repository.Packages).Count());
            Assert.AreEqual("B", cache.Repositories.SelectMany(repository => repository.Packages).First().Id);
        }
Beispiel #8
0
        public void TestLastCacheBuildStampSet() {
            var cache = new RepositoryCache();
            var localRepository = new MockPackageRepository();

            cache.Add("localhost");

            cache.SourceRepositories.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "1.0.0",
                    Tags = "Procon Potato Tag2",
                    IsLatestVersion = true
                }
            }));

            // Now successfully build the repository..
            cache.Build(localRepository);

            Assert.Greater(cache.Repositories.First(repository => repository.IsOrphanage == false).CacheStamp, DateTime.Now.AddSeconds(-5));
        }