Beispiel #1
0
        public void TestRegistryManagerController()
        {
            Assert.AreEqual(1, RegistryManagerController.AllWrappedRegistries.Count);

            var u = new Uri(Path.GetFullPath(Path.Combine(TestData.PATH,
                                                          "registry2/registry.xml")));

            Assert.AreEqual(ResponseCode.REGISTRY_ADDED,
                            RegistryManagerController.AddRegistry(u));
            Assert.AreEqual(2, RegistryManagerController.AllWrappedRegistries.Count);

            // Cannot add same uri.
            Assert.AreEqual(ResponseCode.REGISTRY_ALREADY_PRESENT,
                            RegistryManagerController.AddRegistry(u));

            // loading the database again should still be in same state
            RegistryManagerController.LoadRegistryDatabase();
            Assert.AreEqual(2, RegistryManagerController.AllWrappedRegistries.Count);

            Assert.AreEqual(ResponseCode.REGISTRY_REMOVED,
                            RegistryManagerController.RemoveRegistry(u));

            // Can't remove it a second time it won't be there.
            Assert.AreEqual(ResponseCode.REGISTRY_NOT_FOUND,
                            RegistryManagerController.RemoveRegistry(u));
        }
Beispiel #2
0
        public void TestPluginManagerController()
        {
            RegistryManagerController.LoadRegistryDatabase();
            Assert.AreEqual(1, RegistryManagerController.AllWrappedRegistries.Count);
            RegistryWrapper r = RegistryManagerController.AllWrappedRegistries[0];

            var u = new Uri(Path.GetFullPath(Path.Combine(
                                                 TestData.PATH, "registry/com.google.unity.example/package-manifest.xml")));

            mockFetcher.AddResponse(u.AbsoluteUri,
                                    File.ReadAllText(u.AbsolutePath),
                                    ResponseCode.FETCH_COMPLETE);

            u = new Uri(Path.GetFullPath(Path.Combine(
                                             TestData.PATH,
                                             "registry/com.google.unity.example/gpm-example-plugin/1.0.0.0/description.xml")));
            mockFetcher.AddResponse(u.AbsoluteUri,
                                    File.ReadAllText(u.AbsolutePath),
                                    ResponseCode.FETCH_COMPLETE);

            // Test ChangeRegistryUriIntoModuleUri.
            var regU    = new Uri(TestableConstants.DefaultRegistryLocation);
            var modName = "apples-oranges";
            var metaLoc = PluginManagerController.ChangeRegistryUriIntoModuleUri(regU, modName);

            Assert.IsTrue(metaLoc.AbsoluteUri.Contains(modName));
            Assert.IsTrue(metaLoc.AbsoluteUri.Contains(Constants.MANIFEST_FILE_NAME));

            // Test GetPluginForRegistry.
            var plugins = PluginManagerController.GetPluginsForRegistry(r, true);

            Assert.AreEqual(1, plugins.Count);
            var packagedPlugin = plugins[0];

            Assert.NotNull(packagedPlugin);
            Assert.AreEqual(r.Model, packagedPlugin.ParentRegistry);

            // Test GenerateDescriptionUri.
            var d = PluginManagerController.GenerateDescriptionUri(metaLoc,
                                                                   packagedPlugin.MetaData);

            Assert.IsTrue(d.AbsoluteUri.Contains(packagedPlugin.MetaData.artifactId));
            Assert.IsTrue(d.AbsoluteUri.Contains(packagedPlugin.MetaData.versioning.release));
            Assert.IsTrue(d.AbsoluteUri.Contains(Constants.DESCRIPTION_FILE_NAME));

            plugins = PluginManagerController.GetPluginsForRegistry(null);
            Assert.AreEqual(0, plugins.Count);

            // Test Refresh.
            PluginManagerController.Refresh(r);
            plugins = PluginManagerController.GetPluginsForRegistry(r);
            Assert.AreEqual(1, plugins.Count);
            packagedPlugin = plugins[0];
            Assert.NotNull(packagedPlugin);
            Assert.AreEqual(r.Model, packagedPlugin.ParentRegistry);
        }