public void TestLoadFullAmountValidating(ConfigBucket config) { try { loader.Load(config); Assert.Fail("Validating need throw InvalidPackageException exception."); } catch (InvalidPackageException ex) { CollectionAssert.AreEqual( new[] { "Property \"version\" is invalid value (invalid-version): Invalid version string \"invalid-version\".", "require.baz : invalid version constraint (Could not parse version constraint \"invalid-require\" : Invalid version string \"invalid-require\")", }, ex.GetErrors()); } CollectionAssert.AreEqual( new[] { "Property \"type\" : invalid value (invalid-type(*)), must match [A-Za-z0-9-]+", "Authors bar email : invalid value (email-invalid), must be a valid email address.", "Property \"foo\" is invalid, please use: email, issues, forum, source, docs, wiki", }, loader.GetWarnings()); }
public void TestNotPluginTypePackage(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package); Assert.AreEqual(0, pluginManager.GetPlugins().Length); }
public void TestNoNameThrowException() { var bucket = new ConfigBucket { Name = string.Empty, }; loader.Load <IPackageRoot>(bucket); }
public void TestLoadFullAmountValidatingWarnings(ConfigBucket config) { var package = loader.Load <IPackageComplete>(config); Assert.IsTrue(string.IsNullOrEmpty(package.GetPackageType())); Assert.AreEqual(2, package.GetSupport().Count); Assert.AreEqual(2, package.GetAuthors().Length); Assert.IsTrue(string.IsNullOrEmpty(package.GetAuthors()[1].Email)); }
public void TestUnsatisfiedApiVersion(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package); var display = tester.GetDisplay(); StringAssert.Contains(display, "plugin was skipped because it requires a Plugin API version"); }
public void TestLoadRepeatedlyPluginAssembly(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package); var display = tester.GetDisplay(); StringAssert.Contains(display, "is loaded repeatedly, auto skip"); }
public void TestPluginAssemblyNotFound(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package); var display = tester.GetDisplay(); StringAssert.Contains(display, "is not found."); }
public void TestReferenceParsing(ConfigBucket bucket) { var package = loader.Load <IPackageRoot>(bucket); CollectionAssert.AreEqual( new SortedDictionary <string, string> { { "foo/aux", "d123456789012345678901234567890123456789" }, { "foo/bar", "a123456789012345678901234567890123456789" }, { "foo/baz", "b123456789012345678901234567890123456789" }, { "foo/boo", "c123456789012345678901234567890123456789" }, }, new SortedDictionary <string, string>(package.GetReferences())); }
public void TestUninstallPackage(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package); pluginManager.UninstallPackage(package); var display = tester.GetDisplay(); StringAssert.Contains(display, "Deactivate foo"); StringAssert.Contains(display, "Deactivate bar"); StringAssert.Contains(display, "Uninstall foo"); StringAssert.Contains(display, "Uninstall bar"); }
public void TestLoadDeprecated() { var config = new ConfigBucket() { Name = "dummy", Version = "1.0.0", Deprecated = "vendor/foo", }; var package = loader.Load(config); Assert.AreEqual("vendor/foo", package.GetReplacementPackage()); Assert.AreEqual(true, package.IsDeprecated); config = new ConfigBucket() { Name = "dummy", Version = "1.0.0", Deprecated = "true", }; package = loader.Load(config); Assert.AreEqual("true", package.GetReplacementPackage()); Assert.AreEqual(true, package.IsDeprecated); config = new ConfigBucket() { Name = "dummy", Version = "1.0.0", Deprecated = string.Empty, }; package = loader.Load(config); Assert.AreEqual(string.Empty, package.GetReplacementPackage()); Assert.AreEqual(false, package.IsDeprecated); config = new ConfigBucket() { Name = "dummy", Version = "1.0.0", Deprecated = null, }; package = loader.Load(config); Assert.AreEqual(null, package.GetReplacementPackage()); Assert.AreEqual(false, package.IsDeprecated); }
public void TestDeactivatePackage(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package); pluginManager.DeactivatePackage(package); dispatcher.Dispatch("foo", this, null); dispatcher.Dispatch("bar", this, null); var display = tester.GetDisplay(); StringAssert.Contains(display, "Deactivate foo"); StringAssert.Contains(display, "Deactivate bar"); StringAssert.That.NotContains(display, "Trigger foo event"); StringAssert.That.NotContains(display, "Trigger bar event"); }
public void TestGetPluginCapabilities(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package); var plugins = pluginManager.GetPlugins(); var foo = Array.Find(plugins, (plugin) => plugin.Name == "foo"); var bar = Array.Find(plugins, (plugin) => plugin.Name == "bar"); var capabilities = pluginManager.GetPluginCapabilities <ICommandProvider>(foo); Assert.AreEqual(1, capabilities.Length); capabilities = pluginManager.GetPluginCapabilities <ICommandProvider>(bar); Assert.AreEqual(0, capabilities.Length); }
public void TestAliasesParsing(ConfigBucket bucket) { var package = loader.Load <IPackageRoot>(bucket); var actual = Arr.Map(package.GetAliases(), (alias) => { return($"{alias.Package}, {alias.Version}, {alias.Alias}, {alias.AliasNormalized}"); }); CollectionAssert.AreEqual( new[] { "foo/bar, dev-bug-fixed, 1.0.x-dev, 1.0.9999999.9999999-dev", "bar/baz, 1.0.9999999.9999999-dev, 1.2.0, 1.2.0.0", "bar/boo, 1.0.5.0, 1.2.x-dev, 1.2.9999999.9999999-dev", }, actual); }
public void TestStabilityFlagsParsing(ConfigBucket bucket) { var package = loader.Load <IPackageRoot>(bucket); Assert.AreEqual(Stabilities.Alpha, package.GetMinimumStability()); CollectionAssert.AreEqual( new SortedDictionary <string, Stabilities> { { "bar/baz", Stabilities.Dev }, { "multi/complex", Stabilities.Dev }, { "multi/lowest-wins", Stabilities.Dev }, { "multi/or", Stabilities.Dev }, { "multi/without-flags1", Stabilities.Dev }, { "multi/without-flags2", Stabilities.Alpha }, { "qux/quux", Stabilities.RC }, }, new SortedDictionary <string, Stabilities>(package.GetStabilityFlags())); }
public void TestMissingRequiredData(ConfigBucket bucket, string expectedExceptionMessage) { var package = new LoaderPackage().Load(bucket); try { pluginManager.ActivatePackages(package); Assert.Fail($"Expected throw exception, and contains error message: {expectedExceptionMessage}"); } catch (RuntimeException ex) { if (!ex.Message.Contains(expectedExceptionMessage, StringComparison.Ordinal)) { Assert.Fail($"Did not contain the expected exception message, expcted: \"{expectedExceptionMessage}\", actual: \"{ex.Message}\""); } } }
public void TestGetAllCapabilities(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package); var capabilities = pluginManager.GetAllCapabilities <ICommandProvider>(bucket, io); Assert.AreEqual(1, capabilities.Length); var command = capabilities[0].GetCommands().First(); var testerCommand = new TesterCommand(command); Assert.AreEqual(ExitCodes.Normal, testerCommand.Execute()); var display = testerCommand.GetDisplay(); StringAssert.Contains(display, "Command foo"); }
public void TestLoadInstalledPlugins(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); repositoryInstalled.Setup((o) => o.GetPackages()).Returns(new[] { package, }); pluginManager.LoadInstalledPlugins(); dispatcher.Dispatch("foo", this, null); dispatcher.Dispatch("bar", this, null); var display = tester.GetDisplay(); StringAssert.Contains(display, "Activate foo"); StringAssert.Contains(display, "Activate bar"); StringAssert.Contains(display, "Trigger foo event"); StringAssert.Contains(display, "Trigger bar event"); }
public void TestRequireSelfThrowException(ConfigBucket bucket) { loader.Load <IPackageRoot>(bucket); }
public void TestUnallowedPackageTypes(Type type) { var bucket = new ConfigBucket(); loader.Load(bucket, type); }
public void TestActivatePackagesFailOnMissing(ConfigBucket bucket) { var package = new LoaderPackage().Load(bucket); pluginManager.ActivatePackages(package, true); }
public void TestLoadFullAmount(ConfigBucket config) { config.Dist = new ConfigResource() { Type = "zip", Uri = "https://github.com/foo/bar.zip", Shasum = "foo", Reference = "1.0.0", Mirrors = new[] { "foo" }, }; config.Source = new ConfigResource() { Type = "vcs", Uri = "https://github.com/foo/bar.git", Reference = "master", Mirrors = new[] { "bar" }, }; var package = loader.Load <IPackageComplete>(config); Assert.AreEqual("foobar", package.GetName()); Assert.AreEqual("fooBar", package.GetNamePretty()); Assert.AreEqual("1.0.0", package.GetVersionPretty()); Assert.AreEqual(new DateTime(2019, 7, 9), package.GetReleaseDate()); Assert.AreEqual("This is foobar's description.", package.GetDescription()); Assert.AreEqual("foo, bar, foobar", string.Join(", ", package.GetKeywords())); Assert.AreEqual("https://github.com/foo/bar", package.GetHomepage()); Assert.AreEqual(PackageType.Library, package.GetPackageType()); Assert.AreEqual("http://github.com/notification", package.GetNotificationUri()); CollectionAssert.AreEqual( new[] { "foobar requires foo ^1.0", "foobar requires bar ~2.2", }, Arr.Map(package.GetRequires(), (link) => link.ToString())); CollectionAssert.AreEqual( new[] { "foobar requires-dev (for development) foo-dev ^1.0", "foobar requires-dev (for development) bar-dev ~2.2", }, Arr.Map(package.GetRequiresDev(), (link) => link.ToString())); CollectionAssert.AreEqual( new[] { "foobar replaces foo-replace 1.6", }, Arr.Map(package.GetReplaces(), (link) => link.ToString())); CollectionAssert.AreEqual( new[] { "foobar provides foo-provide 1.2", }, Arr.Map(package.GetProvides(), (link) => link.ToString())); CollectionAssert.AreEqual( new[] { "foobar conflicts bar-conflict 2.7", }, Arr.Map(package.GetConflicts(), (link) => link.ToString())); CollectionAssert.AreEqual( new[] { "bar:bar-suggest", }, Arr.Map( new SortedDictionary <string, string>(package.GetSuggests()), (suggest) => $"{suggest.Key}:{suggest.Value}")); CollectionAssert.AreEqual( new[] { "email:[email protected]", "issues:https://github.com/foo/bar/issues", }, Arr.Map( new SortedDictionary <string, string>(package.GetSupport()), (support) => $"{support.Key}:{support.Value}")); CollectionAssert.AreEqual( new[] { "aux:auux", "foo:bar", }, Arr.Map( new SortedDictionary <string, string>(package.GetScripts()), (script) => $"{script.Key}:{script.Value}")); Assert.AreEqual("foo", string.Join(", ", Arr.Map(package.GetAuthors(), (author) => author.Name))); Assert.AreEqual("mit", string.Join(", ", package.GetLicenses())); Assert.IsFalse(package.IsDeprecated); Assert.AreEqual("release/", string.Join(", ", package.GetArchives())); Assert.AreEqual("bin/", string.Join(", ", package.GetBinaries())); Assert.AreEqual("foo/bar", (string)package.GetExtra()["plugin"][0]); Assert.AreEqual("zip", package.GetDistType()); Assert.AreEqual("https://github.com/foo/bar.zip", package.GetDistUri()); Assert.AreEqual("1.0.0", package.GetDistReference()); Assert.AreEqual("foo", package.GetDistShasum()); Assert.AreEqual("foo", string.Join(", ", package.GetDistMirrors())); Assert.AreEqual("vcs", package.GetSourceType()); Assert.AreEqual("https://github.com/foo/bar.git", package.GetSourceUri()); Assert.AreEqual("master", package.GetSourceReference()); Assert.AreEqual("bar", string.Join(", ", package.GetSourceMirrors())); }