Esempio n. 1
0
        public void TestBeforeSourcePackageFetch()
        {
            var before = false;

            var sources = new ConcurrentDictionary<String, IPackageRepository>();

            sources.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "1.0.0"
                }
            }));

            var packages = new ServicePackageManager() {
                LocalRepository = new MockPackageRepository() {
                    Uri = Defines.PackagesDirectory.FullName
                },
                SourceRepositories = sources,
                BeforeSourcePackageFetch = () => before = true,
                PackageManagerDispatch = new MockPackageManagerDispatch()
            };

            packages.MergePackage("localhost", "A");

            Assert.IsTrue(before);
        }
Esempio n. 2
0
        public void TestBeforeRepositoryInitialize()
        {
            var before = false;

            var packages = new ServicePackageManager() {
                BeforeRepositoryInitialize = () => before = true,
                PackageManagerDispatch = new MockPackageManagerDispatch()
            };

            packages.MergePackage("localhost", "A");

            Assert.IsTrue(before);
        }
Esempio n. 3
0
        public void TestInstallAlreadyExistsCanceled()
        {
            var canceled = false;

            var sources = new ConcurrentDictionary<String, IPackageRepository>();

            sources.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "1.0.0",
                    IsLatestVersion = true
                }
            }));

            var packages = new ServicePackageManager() {
                LocalRepository = new MockPackageRepository(new List<IPackage>() {
                    new DataServicePackage() {
                        Id = "A",
                        Version = "1.0.0"
                    }
                }) {
                    Uri = Defines.PackagesDirectory.FullName
                },
                SourceRepositories = sources,
                PackageActionCanceled = packageId => canceled = true,
                PackageManagerDispatch = new MockPackageManagerDispatch()
            };

            packages.MergePackage("localhost", "A");

            Assert.IsTrue(canceled);
        }
Esempio n. 4
0
        public void TestUpdateDispatched()
        {
            var dispatcher = new MockPackageManagerDispatch();

            var sources = new ConcurrentDictionary<String, IPackageRepository>();

            sources.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "2.0.0",
                    IsLatestVersion = true
                }
            }));

            var packages = new ServicePackageManager() {
                LocalRepository = new MockPackageRepository(new List<IPackage>() {
                    new DataServicePackage() {
                        Id = "A",
                        Version = "1.0.0"
                    }
                }) {
                    Uri = Defines.PackagesDirectory.FullName
                },
                PackageManagerDispatch = dispatcher,
                SourceRepositories = sources
            };

            packages.MergePackage("localhost", "A");

            Assert.IsTrue(dispatcher.DispatchedUpdatePackage);
        }
Esempio n. 5
0
        public void TestOnRepositoryExceptionUpdatePackage()
        {
            var hint = "";

            var sources = new ConcurrentDictionary<String, IPackageRepository>();

            sources.TryAdd("localhost", new MockPackageRepository(new List<IPackage>() {
                new DataServicePackage() {
                    Id = "A",
                    Version = "2.0.0",
                    IsLatestVersion = true
                }
            }));

            var packages = new ServicePackageManager() {
                LocalRepository = new MockPackageRepository(new List<IPackage>() {
                    new DataServicePackage() {
                        Id = "A",
                        Version = "1.0.0"
                    }
                }) {
                    Uri = Defines.PackagesDirectory.FullName
                },
                SourceRepositories = sources,
                RepositoryException = (h, exception) => hint = h
            };

            packages.MergePackage("localhost", "A");

            Assert.AreEqual("ServicePackages.MergePackage.UpdatePackage", hint);
        }
Esempio n. 6
0
        public void TestOnRepositoryExceptionGeneral()
        {
            var hint = "";

            var packages = new ServicePackageManager() {
                RepositoryException = (h, exception) => hint = h,
                PackageManagerDispatch = new MockPackageManagerDispatch()
            };

            packages.MergePackage("localhost", "A");

            Assert.AreEqual("ServicePackages.MergePackage.GeneralCatch", hint);
        }