Example #1
0
        public void InstanceUnicityTest()
        {
            Upfile upA = Upfile.Instance();
            Upfile upB = Upfile.Instance();

            Assert.AreSame(upA, upB);
        }
Example #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);
            }
        }
Example #3
0
 public static void ResetInstances()
 {
     instance = null;
     Upfile.ResetInstance();
     Upbring.ResetInstance();
     InitializeInstance();
 }
Example #4
0
        public void FromXmlWhenAbsentTest()
        {
            try
            {
                Directory.CreateDirectory(temp_dir);
                Directory.SetCurrentDirectory(temp_dir);
                string repo_path = Path.Combine(temp_dir, Path.GetRandomFileName());
                Directory.CreateDirectory(repo_path);

                Upfile dummy = new Upfile()
                {
                    Configuration = new Configuration()
                    {
                        RepositoryPath = new PathConfiguration()
                        {
                            Location = repo_path
                        }
                    },
                    Dependencies = new DependencyDefinition[0],
                    Repositories = new Repository[0],
                    UnityVersion = "foo"
                };
                UpfileExposer.SetInstance(dummy);

                Upbring.InitializeInstance();

                CollectionAssert.IsEmpty(Upbring.Instance().InstalledPackage);
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
                Directory.Delete(temp_dir, true);
            }
        }
Example #5
0
 public static void ResetInstances()
 {
     Debug.Log("---> Resetting instances : ");
     instance = null;
     Upfile.ResetInstance();
     Upbring.ResetInstance();
     InitializeInstance();
 }
Example #6
0
        private void UpdatePackage(Upset package, TemporaryDirectory td)
        {
            NukePackage(package.PackageName);

            DependencyDefinition definition = Upfile.Instance().Dependencies.First(dep => dep.Name == package.PackageName);

            InstallPackage(package, td, definition, true);
        }
        public void WhenUpfileModifiedNoSkip()
        {
            // Upfile Setup
            upfile_path = Helper.GetLocalFilePath(new string[]
            {
                "..",
                "TestData",
                "CustomizedFileLocation",
                "Upfile_Modified_NoSkip.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/Media"), "Media directory does not exist under Assets");
            Assert.IsTrue(Directory.Exists("Assets/Media/package_c~1.3.5"), "Package directory does not exist under Assets/Media");
            Assert.IsTrue(Directory.Exists("Examples"), "Examples directory does not exist");
            Assert.IsTrue(Directory.Exists("Examples/package_c~1.3.5"), "Package directory does not exist under Examples");
            Assert.IsTrue(Directory.Exists("Examples/package_c~1.3.5/Adv"), "Advanced directory does not exist under Examples/package_c~1.3.5");

            // Files under Assets
            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/Media/package_c~1.3.5/M1.txt"), "File M1 did not get copied to Assets/Media/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Assets/Media/package_c~1.3.5/M2.txt"), "File M2 did not get copied to Assets/Media/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Examples/package_c~1.3.5/E1.txt"), "File E1 did not get copied to Examples/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Examples/package_c~1.3.5/E2.txt"), "File E2 did not get copied to Examples/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Examples/package_c~1.3.5/Adv/E3.txt"), "File E2 did not get copied to Examples/package_c~1.3.5/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");
        }
Example #8
0
        public void LoadXmlPresent()
        {
            string upfilePath = Helper.PathCombine("TestData", "UpfileTest", "Upfile.xml");

            Upfile parsed = Upfile.LoadXml(upfilePath);

            Assert.IsTrue(parsed.Dependencies.Any(dep => string.Equals(dep.Name, "test_package")), "No correct dependency found");
            Assert.IsTrue(parsed.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path", "To", "Some", "Repository"))), "No correct repository found");
        }
Example #9
0
        public void LoadAbsentOverrideTest()
        {
            string upfilePath         = Helper.PathCombine("TestData", "UpfileTest", "Upfile.xml");
            string upfileOverridePath = Helper.PathCombine("TestData", "UpfileTest", "NoUpfileInIt", "UpfileOverride.xml");
            Upfile upfile             = Upfile.LoadXml(upfilePath);

            upfile.LoadOverrides(upfileOverridePath);

            Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path", "To", "Some", "Repository"))), "Original repository not found");
            Assert.IsFalse(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path", "To", "Another", "Repository"))), "Loaded absent file");
        }
Example #10
0
        public void SaveFileTest()
        {
            try
            {
                Directory.CreateDirectory(temp_dir);
                Directory.SetCurrentDirectory(temp_dir);

                string repo_path = Path.Combine(temp_dir, Path.GetRandomFileName());
                Directory.CreateDirectory(repo_path);

                Upfile dummy = new Upfile()
                {
                    Configuration = new Configuration()
                    {
                        RepositoryPath = new PathConfiguration()
                        {
                            Location = repo_path
                        }
                    },
                    Dependencies = new DependencyDefinition[0],
                    Repositories = new Repository[0],
                    UnityVersion = "foo"
                };
                UpfileExposer.SetInstance(dummy);

                InstalledPackage package_A = new InstalledPackage()
                {
                    Name = "packageA", Install = new InstallSpec[0], Version = "0.0.0"
                };
                Upbring test = new Upbring()
                {
                    InstalledPackage = new InstalledPackage[] { package_A }
                };

                test.SaveFile();

                XmlSerializer serializer = new XmlSerializer(typeof(Upbring));
                Upbring       parsed;
                using (FileStream fs = new FileStream(Path.Combine(repo_path, "Upbring.xml"), FileMode.Open))
                {
                    parsed = serializer.Deserialize(fs) as Upbring;
                }

                Assert.That(parsed.InstalledPackage.Any(p =>
                                                        p.Name == test.InstalledPackage[0].Name &&
                                                        p.Version == test.InstalledPackage[0].Version
                                                        ));
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
                Directory.Delete(temp_dir, true);
            }
        }
Example #11
0
        public void LoadPresentOverrideTest()
        {
            string upfilePath         = Helper.PathCombine("TestData", "UpfileTest", "Upfile.xml");
            string upfileOverridePath = Helper.PathCombine("TestData", "UpfileTest", "UpliftSettings.xml");
            Upfile upfile             = Upfile.LoadXml(upfilePath);

            upfile.overridePath = upfileOverridePath;
            upfile.LoadOverrides();

            Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path", "To", "Some", "Repository"))), "Original repository not found");
            Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path", "To", "Another", "Repository"))), "Override repository not found");
        }
Example #12
0
        public void UpdatePackage(Upset package, TemporaryDirectory td)
        {
            Upbring upbring = Upbring.Instance();

            // Nuking previous version
            InstalledPackage installedPackage = upbring.GetInstalledPackage(package.PackageName);

            installedPackage.Nuke();

            DependencyDefinition definition = Upfile.Instance().Dependencies.First(dep => dep.Name == package.PackageName);

            InstallPackage(package, td, definition);
        }
Example #13
0
        public void LoadXmlPresent()
        {
            string upfilePath = string.Join(Path.DirectorySeparatorChar.ToString(), new string[]
            {
                "TestData",
                "UpfileTest",
                "Upfile.xml"
            });

            Upfile parsed = Upfile.LoadXml(upfilePath);

            Assert.IsTrue(parsed.Dependencies.Any(dep => string.Equals(dep.Name, "test_package")), "No correct dependency found");
            Assert.IsTrue(parsed.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, "Path\\To\\Some\\Repository")), "No correct repository found");
        }
Example #14
0
        public void GetDestinationForDefault()
        {
            Upfile upfile = new Upfile();

            upfile.Configuration = new Configuration
            {
                BaseInstallPath = new PathConfiguration {
                    Location = "foo"
                }
            };

            InstallSpec test_spec = new InstallSpecPath();

            Assert.AreEqual("foo", upfile.GetDestinationFor(test_spec).Location);
        }
Example #15
0
        static Initialize()
        {
            Debug.Log("Upfile loading...");
            if (!Upfile.CheckForUpfile())
            {
                Debug.Log("No Upfile was found at the root of your project, Uplift created a sample one for you to start working on");
                SampleFile.CreateSampleUpfile();
            }

            if (!IsInitialized())
            {
                UpliftManager.Instance().InstallDependencies(strategy: UpliftManager.InstallStrategy.ONLY_LOCKFILE, refresh: true);
                MarkAsInitialized();
            }
        }
Example #16
0
        public void LoadXmlAbsent()
        {
            string upfilePath = Helper.PathCombine("TestData", "UpfileTest", "NoUpfileInIt", "Upfile.xml");

            bool caught = false;

            try
            {
                Upfile.LoadXml(upfilePath);
            }
            catch
            {
                caught = true;
            }
            Assert.IsTrue(caught);
        }
Example #17
0
        public void GetDestinationForPlugin()
        {
            Upfile upfile = new Upfile();

            upfile.Configuration = new Configuration
            {
                PluginPath = new PathConfiguration {
                    Location = "foo"
                }
            };

            InstallSpec test_spec = new InstallSpecPath
            {
                Type = InstallSpecType.Plugin
            };

            Assert.AreEqual("foo", upfile.GetDestinationFor(test_spec).Location);
        }
Example #18
0
        static Initialize()
        {
            Debug.Log("Using Uplift version " + About.Version);
            if (!Upfile.CheckForUpfile())
            {
                Debug.Log("No Upfile was found at the root of your project, Uplift created a sample one for you to start working on");
                SampleFile.CreateSampleUpfile();
            }

            if (LockFileTracker.HasChanged())
            {
                UpliftManager.ResetInstances();
                UpliftManager.Instance().InstallDependencies(strategy: UpliftManager.InstallStrategy.ONLY_LOCKFILE);
                LockFileTracker.SaveState();
            }

            Updater.CheckForUpdate();
        }
Example #19
0
        private void UpdatePackage(Upset package, TemporaryDirectory td, bool updateLockfile)
        {
            NukePackage(package.PackageName);

            // First or default returns the first DependencyDefinition which satistfies dep.Name == package.PackageName
            // If no elements meets this condition a Default value for DependencyDefinition is returned which, for our implementation, is null.
            DependencyDefinition definition = Upfile.Instance().Dependencies.FirstOrDefault(dep => dep.Name == package.PackageName);

            if (definition == null)
            {
                definition = new DependencyDefinition()
                {
                    Name = package.PackageName, Version = package.PackageVersion
                };
            }

            InstallPackage(package, td, definition, updateLockfile);
        }
Example #20
0
        public void CheckForUpfileAbsentTest()
        {
            string pwd    = Directory.GetCurrentDirectory();
            string tmpDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Directory.CreateDirectory(tmpDir);
            try
            {
                Directory.SetCurrentDirectory(tmpDir);

                Assert.IsFalse(Upfile.CheckForUpfile());
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
                Directory.Delete(tmpDir, true);
            }
        }
Example #21
0
        public void LoadPresentOverrideTest()
        {
            string upfilePath = string.Join(Path.DirectorySeparatorChar.ToString(), new string[]
            {
                "TestData",
                "UpfileTest",
                "Upfile.xml"
            });
            string upfileOverridePath = string.Join(Path.DirectorySeparatorChar.ToString(), new string[]
            {
                "TestData",
                "UpfileTest",
                "UpfileOverride.xml"
            });
            Upfile upfile = Upfile.LoadXml(upfilePath);

            upfile.LoadOverrides(upfileOverridePath);

            Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, "Path\\To\\Some\\Repository")), "Original repository not found");
            Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, "Path\\To\\Another\\Repository")), "Override repository not found");
        }
Example #22
0
        public void InstallDependencies(IDependencySolver dependencySolver)
        {
            //FIXME: We should check for all repositories, not the first one
            //FileRepository rt = (FileRepository) Upfile.Repositories[0];
            upfile = Upfile.Instance();

            PackageList pList = PackageList.Instance();

            DependencyDefinition[] dependencies = dependencySolver.SolveDependencies(upfile.Dependencies);
            foreach (DependencyDefinition packageDefinition in dependencies)
            {
                PackageRepo result = pList.FindPackageAndRepository(packageDefinition);
                if (result.Repository != null)
                {
                    using (TemporaryDirectory td = result.Repository.DownloadPackage(result.Package))
                    {
                        InstallPackage(result.Package, td, packageDefinition);
                    }
                }
            }
        }
Example #23
0
        public void CheckForUpfilePresentTest()
        {
            string pwd    = Directory.GetCurrentDirectory();
            string tmpDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Directory.CreateDirectory(tmpDir);
            try
            {
                Directory.SetCurrentDirectory(tmpDir);

                // Create dummy Upfile
                File.Create("Upfile.xml").Dispose();

                Assert.IsTrue(Upfile.CheckForUpfile());
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
                Directory.Delete(tmpDir, true);
            }
        }
Example #24
0
        private static void CheckDependencies()
        {
            Upbring     upbring     = Upbring.Instance();
            Upfile      upfile      = Upfile.Instance();
            PackageList packageList = PackageList.Instance();

            PackageRepo[] packageRepos = packageList.GetAllPackages();

            bool any_installed =
                upbring.InstalledPackage != null &&
                upbring.InstalledPackage.Length != 0;

            foreach (DependencyDefinition dependency in upfile.Dependencies)
            {
                string name      = dependency.Name;
                bool   installed =
                    any_installed &&
                    upbring.InstalledPackage.Any(ip => ip.Name == name);
                bool   installable   = packageRepos.Any(pr => pr.Package.PackageName == name);
                string latest        = installable ? packageList.GetLatestPackage(name).Package.PackageVersion : "";
                string string_latest = string.IsNullOrEmpty(latest) ? "No version available in any repository" : "Latest version is " + latest;
                if (installed)
                {
                    string installed_version = upbring.GetInstalledPackage(name).Version;
                    if (installed_version != latest)
                    {
                        Debug.Log(string.Format("Package {0} is outdated: installed version is {1}, latest is {2}", name, installed_version, string_latest));
                    }
                    else
                    {
                        Debug.Log(string.Format("Package {0} is up-to-date ({1})", name, installed_version));
                    }
                }
                else
                {
                    Debug.Log(string.Format("Package {0} is not installed ({1})", name, string_latest));
                }
            }
        }
Example #25
0
        public void LoadXmlAbsent()
        {
            string upfilePath = string.Join(Path.DirectorySeparatorChar.ToString(), new string[]
            {
                "TestData",
                "UpfileTest",
                "NoUpfileInIt",
                "Upfile.xml"
            });

            bool caught = false;

            try
            {
                Upfile.LoadXml(upfilePath);
            }
            catch
            {
                caught = true;
            }
            Assert.IsTrue(caught);
        }
Example #26
0
        public void RemoveFileTest()
        {
            try
            {
                Directory.CreateDirectory(temp_dir);
                Directory.SetCurrentDirectory(temp_dir);

                string repo_path = Path.Combine(temp_dir, Path.GetRandomFileName());
                Directory.CreateDirectory(repo_path);

                Upfile dummy = new Upfile()
                {
                    Configuration = new Configuration()
                    {
                        RepositoryPath = new PathConfiguration()
                        {
                            Location = repo_path
                        }
                    },
                    Dependencies = new DependencyDefinition[0],
                    Repositories = new Repository[0],
                    UnityVersion = "foo"
                };
                UpfileExposer.SetInstance(dummy);

                string upbring_path = Path.Combine(repo_path, "Upbring.xml");
                File.Create(upbring_path).Dispose();

                Upbring.RemoveFile();
                Assert.IsFalse(File.Exists(upbring_path));
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
                Directory.Delete(temp_dir, true);
            }
        }
Example #27
0
        internal static Upfile LoadTestXml(string path)
        {
            StrictXmlDeserializer <Upfile> deserializer = new StrictXmlDeserializer <Upfile>();

            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                Upfile upfile = deserializer.Deserialize(fs);

                upfile.MakePathConfigurationsOSFriendly();

                if (upfile.Repositories != null)
                {
                    foreach (Repository repo in upfile.Repositories)
                    {
                        if (repo is FileRepository)
                        {
                            (repo as FileRepository).Path = FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path);
                        }
                    }
                }

                return(upfile);
            }
        }
        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");
        }
Example #29
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);
            }
        }
Example #30
0
 static Initialize()
 {
     Upfile.Instance();
 }