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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void TestDispose() { PackagesController packages = new PackagesController(); packages.Dispose(); Assert.IsNull(packages.GroupedVariableListener); Assert.IsNull(packages.LocalRepository); Assert.IsNull(packages.Cache); }
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); }