示例#1
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);
            }
        }
示例#2
0
        public void FromXmlWhenPresentTest()
        {
            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 }
                };
                XmlSerializer serializer = new XmlSerializer(typeof(Upbring));
                using (FileStream fs = new FileStream(Path.Combine(repo_path, "Upbring.xml"), FileMode.Create))
                {
                    serializer.Serialize(fs, test);
                }
                Upbring.InitializeInstance();

                Assert.That(Upbring.Instance().InstalledPackage.Any(p =>
                                                                    p.Name == package_A.Name &&
                                                                    p.Version == package_A.Version
                                                                    ));
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
                Directory.Delete(temp_dir, true);
            }
        }