public void WhenUpfileNotModified()
        {
            // Upfile Setup
            upfile_path = Helper.GetLocalFilePath(new string[]
            {
                "..",
                "TestData",
                "CustomizedFileLocation",
                "Upfile_NotModified.xml"
            });

            try
            {
                UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Make sure you are running the test from UpliftTesting/TestResults. The Upfile.xml uses the current path to register the repositories.");
                Assert.IsTrue(false, "The test could not run correctly. See console message.");
            }
            upfile = Upfile.Instance();

            manager.InstallDependencies();

            // Directories existence
            Assert.IsTrue(Directory.Exists("UPackages"), "Directory UPackages does not exist");
            Assert.IsTrue(Directory.Exists("UPackages/package_c~1.3.5"), "Package directory does not exist under UPackages");
            Assert.IsTrue(Directory.Exists("UPackages/package_c~1.3.5/Media"), "Media directory does not exist under UPackages/package_c~1.3.5");
            Assert.IsTrue(Directory.Exists("UPackages/package_c~1.3.5/Example"), "Example directory does not exist under UPackages/package_c~1.3.5");
            Assert.IsTrue(Directory.Exists("UPackages/package_c~1.3.5/Example/Adv"), "Example advanced directory does not exist under UPackages/package_c~1.3.5");
            Assert.IsTrue(Directory.Exists("Assets"), "Directory Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages"), "Directory UPackages under Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages/package_c~1.3.5"), "Package directory does not exist under Assets/UPackages");
            Assert.IsTrue(Directory.Exists("Assets/UPackages/package_c~1.3.5/Media"), "Media directory does not exist under Assets/UPackages/package_c~1.3.5");
            Assert.IsTrue(Directory.Exists("Assets/UPackages/package_c~1.3.5/Example"), "Example directory does not exist under Assets/UPackages/package_c~1.3.5");
            Assert.IsTrue(Directory.Exists("Assets/UPackages/package_c~1.3.5/Example/Adv"), "Example advanced directory does not exist under Assets/UPackages/package_c~1.3.5");

            // Files under Assets/UPackages
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/C1.cs"), "File C1 did not get copied to Assets/UPackages/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/C2.cs"), "File C2 did not get copied to Assets/UPackages/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/Media/M1.txt"), "File M1 did not get copied to Assets/UPackages/package_c~1.3.5/Media");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/Media/M2.txt"), "File M2 did not get copied to Assets/UPackages/package_c~1.3.5/Media");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/Example/E1.txt"), "File E1 did not get copied to Assets/UPackages/package_c~1.3.5/Example");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/Example/E2.txt"), "File E2 did not get copied to Assets/UPackages/package_c~1.3.5/Example");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/Example/Adv/E3.txt"), "File E2 did not get copied to Assets/UPackages/package_c~1.3.5/Example/Adv");

            // Files under UPackages
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/C1.cs"), "File C1 did not get copied to UPackages/package_c~1.3.5");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/C2.cs"), "File C2 did not get copied to UPackages/package_c~1.3.5");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Media/M1.txt"), "File M1 did not get copied to UPackages/package_c~1.3.5/Media");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Media/M2.txt"), "File M2 did not get copied to UPackages/package_c~1.3.5/Media");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Example/E1.txt"), "File E1 did not get copied to UPackages/package_c~1.3.5/Example");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Example/E2.txt"), "File E2 did not get copied to UPackages/package_c~1.3.5/Example");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Example/Adv/E3.txt"), "File E2 did not get copied to UPackages/package_c~1.3.5/Example/Adv");
        }
예제 #2
0
        protected void Given()
        {
            UpliftManagerExposer.ClearAllInstances();

            pwd = Directory.GetCurrentDirectory();
            Helper.InitializeRunDirectory();

            try
            {
                Directory.SetCurrentDirectory(Helper.testRunDirectoryName);

                // Upfile Setup
                upfile_path = Helper.GetLocalFilePath("..", "TestData", "PackageUpdating", "Upfile.xml");

                try
                {
                    UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
                }
                catch (FileNotFoundException)
                {
                    Console.WriteLine("Make sure you are running the test from UpliftTesting/TestResults. The Upfile.xml uses the current path to register the repositories.");
                }
                upfile  = Upfile.Instance();
                manager = UpliftManager.Instance();

                upfile.Dependencies[0].Version = "1.0.0";
                manager.InstallDependencies();
                upfile.Dependencies[0].Version = "1.0.1";
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
            }
        }
예제 #3
0
        protected void BeforeEach()
        {
            // Move to test running directory
            Directory.SetCurrentDirectory(Helper.testRunDirectoryName);

            //Install Package D
            manager.InstallDependencies();
        }
예제 #4
0
        protected void Given()
        {
            UpliftManagerExposer.ClearAllInstances();

            pwd = Directory.GetCurrentDirectory();
            Helper.InitializeRunDirectory();

            try
            {
                Directory.SetCurrentDirectory(Helper.testRunDirectoryName);

                // Upfile Setup for filler package
                upfile_path = Helper.GetLocalFilePath("..", "TestData", "PackageNuking", "Init_Upfile.xml");

                try
                {
                    UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
                }
                catch (FileNotFoundException)
                {
                    Console.WriteLine("Make sure you are running the test from UpliftTesting/TestResults. The Upfile.xml uses the current path to register the repositories.");
                    Assert.Fail("The test could not run correctly. See console message.");
                }
                UpfileExposer.TestingInstance();
                manager = UpliftManager.Instance();

                // Creating original state
                Directory.CreateDirectory("Assets");
                Directory.CreateDirectory("Assets/Media");

                File.Create("Assets/scriptA.cs").Dispose();
                File.Create("Assets/scriptB.cs").Dispose();
                File.Create("Assets/Media/mediaA.txt").Dispose();
                File.Create("Assets/Media/mediaB.txt").Dispose();

                // Install Filler Package
                manager.InstallDependencies();

                // Save the snapshot
                original_snapshot = GetSnapshot();

                // Proper Upfile Setup
                UpliftManagerExposer.ClearAllInstances();
                UpfileExposer.ClearInstance();
                upfile_path = Helper.GetLocalFilePath("..", "TestData", "PackageNuking", "Upfile.xml");

                try
                {
                    UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
                }
                catch (FileNotFoundException)
                {
                    Console.WriteLine("Make sure you are running the test from UpliftTesting/TestResults. The Upfile.xml uses the current path to register the repositories.");
                    Assert.IsTrue(false, "The test could not run correctly. See console message.");
                }
                Upfile.Instance();
                manager = UpliftManager.Instance();
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
            }
        }
예제 #5
0
        public void WhenInstalling()
        {
            upfile_path = Helper.GetLocalFilePath("..", "TestData", "BasicPackageInstallation", "Upfile.xml");

            try
            {
                UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
            }
            catch (FileNotFoundException)
            {
                UnityEngine.Debug.LogError("The Upfile.xml uses the current path to register the repositories.");
            }
            Upfile.Instance();
            manager = UpliftManager.Instance();

            manager.InstallDependencies();

            // Directories existence
            Assert.IsTrue(Directory.Exists("UPackages"), "Directory UPackages does not exist");
            Assert.IsTrue(Directory.Exists("UPackages/package_a~1.0.0"), "Package directory does not exist under UPackages");
            Assert.IsTrue(Directory.Exists("Assets"), "Directory Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages"), "Directory UPackages under Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages/package_a~1.0.0"), "Package directory does not exist under Assets/UPackages");

            // Files under Assets/UPackages
            Assert.IsTrue(File.Exists("Assets/UPackages/package_a~1.0.0/A1.cs"), "File A1 did not get copied to Assets/UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_a~1.0.0/A2.cs"), "File A2 did not get copied to Assets/UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_a~1.0.0/A3.cs"), "File A3 did not get copied to Assets/UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_a~1.0.0/Upset.xml"), "Upset file did not get copied to Assets/UPackages/package_a~1.0.0");

            // Files under UPackages
            Assert.IsTrue(File.Exists("UPackages/Upbring.xml"), "Upbring file has not been created");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.0/A1.cs"), "File A1 did not get copied to UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.0/A2.cs"), "File A2 did not get copied to UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.0/A3.cs"), "File A3 did not get copied to UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.0/Upset.xml"), "Upset file did not get copied to UPackages/package_a~1.0.0");

            // Upbring validity
            Upbring upbring = Upbring.Instance();

            Assert.IsNotEmpty(upbring.InstalledPackage, "Upbring file did not registered the installation");
            Assert.That(upbring.InstalledPackage.Any(p =>
                                                     p.Name == "package_a" &&
                                                     p.Version == "1.0.0"
                                                     ), "Upbring did not register an installation with the proper package Name and Version");
            Assert.IsNotEmpty(upbring.InstalledPackage[0].Install, "Upbring file did not register file dependencies");

            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "UPackages/package_a~1.0.0" &&
                                                                i.Type == InstallSpecType.Root
                                                                ), "Root installation did not get registered");
            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "Assets/UPackages/package_a~1.0.0/A1.cs" &&
                                                                i.Type == InstallSpecType.Base
                                                                ), "Base installation of A1.cs did not get registered");
            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "Assets/UPackages/package_a~1.0.0/A2.cs" &&
                                                                i.Type == InstallSpecType.Base
                                                                ), "Base installation of A2.cs did not get registered");
            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "Assets/UPackages/package_a~1.0.0/A3.cs" &&
                                                                i.Type == InstallSpecType.Base
                                                                ), "Base installation of A3.cs did not get registered");
            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "Assets/UPackages/package_a~1.0.0/Upset.xml" &&
                                                                i.Type == InstallSpecType.Base
                                                                ), "Base installation of Upset.xml did not get registered");
        }
예제 #6
0
        protected void OnGUI()
        {
            titleContent.text = "Update Utility";

            UpliftManager manager     = UpliftManager.Instance();
            Upbring       upbring     = Upbring.Instance();
            Upfile        upfile      = Upfile.Instance();
            PackageList   packageList = PackageList.Instance();

            PackageRepo[] packageRepos = packageList.GetAllPackages();

            DependencyDefinition[] dependencies = upfile.Dependencies;
            bool any_installed =
                upbring.InstalledPackage != null &&
                upbring.InstalledPackage.Length != 0;

            if (dependencies.Length == 0)
            {
                EditorGUILayout.HelpBox("It seems that you didn't specify any dependency in the Upfile. Try refreshing it if you did.", MessageType.Warning);
            }
            else
            {
                foreach (DependencyDefinition dependency in dependencies)
                {
                    string name = dependency.Name;
                    EditorGUILayout.LabelField(name + ":", EditorStyles.boldLabel);
                    bool installable = packageRepos.Any(pr => pr.Package.PackageName == name);
                    bool installed   =
                        any_installed &&
                        upbring.InstalledPackage.Any(ip => ip.Name == name);
                    string installed_version = installed ? upbring.GetInstalledPackage(name).Version : "";

                    if (installed)
                    {
                        EditorGUILayout.LabelField("- Installed version is " + installed_version);
                    }
                    else
                    {
                        EditorGUILayout.LabelField("- Not yet installed");
                    }

                    if (!installable)
                    {
                        EditorGUILayout.HelpBox("No repository contains this package. Try specifying one whith this package in.", MessageType.Warning);
                    }
                    else
                    {
                        PackageRepo latestPackageRepo = packageList.GetLatestPackage(name);
                        string      latest_version    = latestPackageRepo.Package.PackageVersion;

                        EditorGUILayout.LabelField(string.Format("- Latest version is: {0} (from {1})", latest_version, latestPackageRepo.Repository.ToString()));

                        GUI.enabled = installed && installed_version != latest_version;
                        if (GUILayout.Button("Update to " + latest_version))
                        {
                            Debug.Log(string.Format("Updating package {0} (to {1})", name, latest_version));
                            manager.UpdatePackage(latestPackageRepo);

                            AssetDatabase.Refresh();

                            Repaint();
                        }
                        GUI.enabled = true;
                    }

                    EditorGUILayout.Space();
                }

                if (GUILayout.Button("Install all dependencies"))
                {
                    manager.InstallDependencies();

                    AssetDatabase.Refresh();

                    Repaint();
                }
                GUI.enabled = any_installed;
                if (GUILayout.Button("Update all installed packages"))
                {
                    foreach (InstalledPackage package in upbring.InstalledPackage)
                    {
                        PackageRepo latestPackageRepo = packageList.GetLatestPackage(package.Name);
                        if (package.Version != latestPackageRepo.Package.PackageVersion)
                        {
                            Debug.Log(string.Format("Updating package {0} (to {1})", package.Name, latestPackageRepo.Package.PackageVersion));
                            manager.UpdatePackage(latestPackageRepo);
                        }
                    }

                    AssetDatabase.Refresh();

                    Repaint();
                }
                GUI.enabled = true;
                if (GUILayout.Button("Refresh Upfile"))
                {
                    Upfile.Instance();

                    Repaint();
                }
            }
        }
예제 #7
0
        public void WhenUpdating()
        {
            manager.InstallDependencies();
            Upbring upbring = Upbring.Instance();

            // -- 1.0.0 UNINSTALLATION --
            // Directories absence
            Assert.IsFalse(Directory.Exists("UPackages/package_a~1.0.0"), "Package directory still exists under UPackages");
            Assert.IsFalse(Directory.Exists("Assets/UPackages/package_a~1.0.0"), "Package directory still exists under Assets/UPackages");

            // Upbring validity
            Assert.IsFalse((upbring.InstalledPackage.Any(p =>
                                                         p.Name == "package_a" &&
                                                         p.Version == "1.0.0"
                                                         )), "Upbring did not properly forget the outdated installation");

            // -- 1.0.1 INSTALLATION --
            // Directories existence
            Assert.IsTrue(Directory.Exists("UPackages"), "Directory UPackages does not exist");
            Assert.IsTrue(Directory.Exists("UPackages/package_a~1.0.1"), "Package directory does not exist under UPackages");
            Assert.IsTrue(Directory.Exists("Assets"), "Directory Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages"), "Directory UPackages under Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages/package_a~1.0.1"), "Package directory does not exist under Assets/UPackages");

            // Files under UPackages
            Assert.IsTrue(File.Exists("UPackages/Upbring.xml"), "Upbring file has not been created");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.1/A1.cs"), "File A1 did not get copied to UPackages/package_a~1.0.1");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.1/A2.cs"), "File A2 did not get copied to UPackages/package_a~1.0.1");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.1/A3.cs"), "File A3 did not get copied to UPackages/package_a~1.0.1");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.1/Upset.xml"), "Upset file did not get copied to UPackages/package_a~1.0.1");

            // Upbring validity
            Assert.IsNotEmpty(upbring.InstalledPackage, "Upbring file did not registered the new installation");
            Assert.That(upbring.InstalledPackage.Any(p =>
                                                     p.Name == "package_a" &&
                                                     p.Version == "1.0.1"
                                                     ), "Upbring did not register an installation with the proper package Name and Version");
            Assert.IsNotEmpty(upbring.InstalledPackage[0].Install, "Upbring file did not register file dependencies");
            // FIXME: Refactor the test to take into account the GUID tracking

            /*
             * Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
             * i.Path == Path.Combine("UPackages", "package_a~1.0.1") &&
             * i.Type == InstallSpecType.Root
             * ), "Root installation did not get registered");
             * Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
             * i.Path == Path.Combine(new string[] { "Assets", "UPackages", "package_a~1.0.1", "A1.cs" }) &&
             * i.Type == InstallSpecType.Base
             * ), "Base installation of A1.cs did not get registered");
             * Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
             * i.Path == Path.Combine(new string[] { "Assets", "UPackages", "package_a~1.0.1", "A2.cs" }) &&
             * i.Type == InstallSpecType.Base
             * ), "Base installation of A2.cs did not get registered");
             * Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
             * i.Path == Path.Combine(new string[] { "Assets", "UPackages", "package_a~1.0.1", "A3.cs" }) &&
             * i.Type == InstallSpecType.Base
             * ), "Base installation of A3.cs did not get registered");
             * Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
             * i.Path == Path.Combine(new string[] { "Assets", "UPackages", "package_a~1.0.1", "Upset.xml" }) &&
             * i.Type == InstallSpecType.Base
             * ), "Base installation of Upset.xml did not get registered");
             */
        }