コード例 #1
0
        public void TestPackageGroupSetupOrderReversed() {
            var variables = new VariableController();

            var @namespace = "";

            var packages = new PackagesController() {
                Shared = {
                    Variables = variables
                }
            }.Execute() as PackagesController;

            variables.Set(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.VariablesSet
            }, CommonVariableNames.PackagesConfigGroups, new List<String>() {
                @namespace
            });

            variables.Set(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.VariablesSet
            }, VariableModel.NamespaceVariableName(@namespace, CommonVariableNames.PackagesRepositoryUri), "path-to-repository");

            Assert.IsNotEmpty(packages.Cache.Repositories);
            Assert.AreEqual("path-to-repository", packages.Cache.Repositories.FirstOrDefault().Uri);
        }
コード例 #2
0
        public void TestRepositoryCacheBuilt() {
            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
                }
            }));

            PackagesController packages = new PackagesController() {
                LocalRepository = localRepository,
                Cache = cache
            };

            packages.Poke();

            Assert.IsNotNull(packages.Cache.Repositories.First(repository => repository.Uri == "localhost"));
            Assert.AreEqual("A", packages.Cache.Repositories.First(repository => repository.Uri == "localhost").Packages.First().Id);
            Assert.AreEqual(PackageState.UpdateAvailable, packages.Cache.Repositories.First(repository => repository.Uri == "localhost").Packages.First().State);
        }
コード例 #3
0
        public void TestResultSuccess() {
            PackagesController packages = new PackagesController();

            ICommandResult result = packages.Tunnel(CommandBuilder.PackagesRemoveRepository("https://teamcity.myrcon.com/nuget").SetOrigin(CommandOrigin.Local));

            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
コード例 #4
0
        public void TestResultDoesNotExists() {
            PackagesController packages = new PackagesController();

            ICommandResult result = packages.Tunnel(CommandBuilder.PackagesUninstallPackage("this-does-not-exist").SetOrigin(CommandOrigin.Local));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.DoesNotExists, result.CommandResultType);
        }
コード例 #5
0
        public void TestResultInvalidParameter() {
            PackagesController packages = new PackagesController();

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

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.InvalidParameter, result.CommandResultType);
        }
コード例 #6
0
        public void TestResultSuccess() {
            PackagesController packages = new PackagesController();

            ICommandResult result = packages.Tunnel(CommandBuilder.PackagesFetchPackages().SetOrigin(CommandOrigin.Local));

            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
コード例 #7
0
        public void TestResultInsufficientPermissions() {
            PackagesController packages = new PackagesController();

            ICommandResult result = packages.Tunnel(CommandBuilder.PackagesRemoveRepository("https://teamcity.myrcon.com/nuget").SetOrigin(CommandOrigin.Remote).SetAuthentication(new CommandAuthenticationModel() {
                Username = "******"
            }));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType);
        }
コード例 #8
0
        public void TestResultInsufficientPermissions() {
            PackagesController packages = new PackagesController();

            ICommandResult result = packages.Tunnel(CommandBuilder.PackagesUninstallPackage("id").SetOrigin(CommandOrigin.Remote).SetAuthentication(new CommandAuthenticationModel() {
                Username = "******"
            }));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        public void TestDispose() {
            PackagesController packages = new PackagesController();

            packages.Dispose();

            Assert.IsNull(packages.GroupedVariableListener);
            Assert.IsNull(packages.LocalRepository);
            Assert.IsNull(packages.Cache);
        }
コード例 #11
0
        public void TestRepositoryCacheBuiltEventLogged() {
            EventsController events = new EventsController();

            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
                }
            }));

            PackagesController packages = new PackagesController() {
                LocalRepository = localRepository,
                Cache = cache
            };

            packages.Shared.Events = events;

            packages.Poke();

            Assert.IsNotEmpty(events.LoggedEvents);
            Assert.AreEqual("PackagesCacheRebuilt", events.LoggedEvents.First().Name);
            Assert.AreEqual("A", events.LoggedEvents.First().Now.Repositories.First(repository => repository.Uri == "localhost").Packages.First().Id);
            Assert.AreEqual(PackageState.UpdateAvailable, events.LoggedEvents.First().Now.Repositories.First(repository => repository.Uri == "localhost").Packages.First().State);
        }