コード例 #1
0
ファイル: ProgramTests.cs プロジェクト: enricedward/UnityGDK
        public void FindSchemaFiles_returns_all_found_schema_files()
        {
            var depOne   = new Program.PackageInfo("dep.one", Path.Combine(packages, "path_of", "dep_one"));
            var depTwo   = new Program.PackageInfo("dep.two", Path.Combine(packages, "com.dep.two.path"));
            var depThree = new Program.PackageInfo("dep.three", relativePackagePath);

            Directory.CreateDirectory(Path.Combine(packages, "path_of", "dep_one", "Schema"));
            Directory.CreateDirectory(Path.Combine(relativePackagePath, "Schema", "nested"));

            var fileOne   = Path.Combine(packages, "path_of", "dep_one", "Schema", "schema_file.schema");
            var fileTwo   = Path.Combine(relativePackagePath, "Schema", "other.schema");
            var fileThree = Path.Combine(relativePackagePath, "Schema", "nested", "nested.schema");

            File.WriteAllText(fileOne, string.Empty);
            File.WriteAllText(Path.Combine(packages, "path_of", "dep_one", "Schema", "schema_file.schema.meta"), string.Empty);
            File.WriteAllText(fileTwo, string.Empty);
            File.WriteAllText(fileThree, string.Empty);

            var packageInfos = new List <Program.PackageInfo>()
            {
                depOne,
                depTwo,
                depThree
            };

            var results = Program.FindSchemaFiles(packageInfos);

            Assert.AreEqual(3, results.Count, "Wrong number of files returned.");
            Assert.Contains(new KeyValuePair <Program.PackageInfo, string>(depOne, fileOne), results);
            Assert.Contains(new KeyValuePair <Program.PackageInfo, string>(depThree, fileTwo), results);
            Assert.Contains(new KeyValuePair <Program.PackageInfo, string>(depThree, fileThree), results);
        }
コード例 #2
0
ファイル: ProgramTests.cs プロジェクト: enricedward/UnityGDK
        public void GetFilesToCopy_returns_destinations_nested_in_package_name()
        {
            var depOne   = new Program.PackageInfo("dep.one", Path.Combine(packages, "path_of", "dep_one"));
            var depThree = new Program.PackageInfo("dep.three", relativePackagePath);

            var fileOne              = Path.Combine(packages, "path_of", "dep_one", "Schema", "schema_file.schema");
            var fileOneDestination   = Path.Combine(schema, Program.FromGdkPackagesDir, depOne.Name, "schema_file.schema");
            var fileTwo              = Path.Combine(relativePackagePath, "Schema", "other.schema");
            var fileTwoDestination   = Path.Combine(schema, Program.FromGdkPackagesDir, depThree.Name, "other.schema");
            var fileThree            = Path.Combine(relativePackagePath, "Schema", "nested", "nested.schema");
            var fileThreeDestination = Path.Combine(schema, Program.FromGdkPackagesDir, depThree.Name, "nested", "nested.schema");

            var schemaFiles = new List <KeyValuePair <Program.PackageInfo, string> >()
            {
                new KeyValuePair <Program.PackageInfo, string>(depOne, fileOne),
                new KeyValuePair <Program.PackageInfo, string>(depThree, fileTwo),
                new KeyValuePair <Program.PackageInfo, string>(depThree, fileThree)
            };

            var results = Program.GetFilesToCopy(schemaFiles, schema);

            Assert.AreEqual(3, results.Count, "Wrong number of files returned");
            Assert.Contains(new KeyValuePair <string, string>(fileOne, fileOneDestination), results);
            Assert.Contains(new KeyValuePair <string, string>(fileTwo, fileTwoDestination), results);
            Assert.Contains(new KeyValuePair <string, string>(fileThree, fileThreeDestination), results);
        }
コード例 #3
0
ファイル: ProgramTests.cs プロジェクト: enricedward/UnityGDK
        public void GetPackageInfos_returns_only_file_dependencies()
        {
            dynamic json     = JsonConvert.DeserializeObject(@"
                {
                    ""dependencies"": {
                        ""with_version"":""1.0.0"",
                        ""dep.one"": ""file:./path_of/dep_one"",
                        ""dep.two"": ""file:com.dep.two.path"",
                        ""dep.three"": ""file:../relative_package_path""
                    }
                }
            ");
            var     depOne   = new Program.PackageInfo("dep.one", Path.Combine(packages, "path_of", "dep_one"));
            var     depTwo   = new Program.PackageInfo("dep.two", Path.Combine(packages, "com.dep.two.path"));
            var     depThree = new Program.PackageInfo("dep.three", relativePackagePath);

            List <Program.PackageInfo> results = Program.GetPackageInfos(json, packages);

            Assert.AreEqual(3, results.Count, "Wrong number of dependencies returned.");
            Assert.Contains(depOne, results);
            Assert.Contains(depTwo, results);
            Assert.Contains(depThree, results);
        }