Example #1
0
        public void Valid_FullyGenerated_FilesAry()
        {
            Directory.CreateDirectory(OutputPath);
            string targetPath = Path.Combine(OutputPath, nameof(Valid_FullyGenerated_FilesAry) + ".json");
            var    task       = new GenerateManifest()
            {
                Id          = "TestPlugin",
                Name        = "Test Plugin",
                Author      = "Zingabopp",
                Version     = "1.0.0",
                GameVersion = "1.14.0",
                Description = "Description of a test plugin.",
                DependsOn   =
                    MockTaskItem.FromDictString("DependsOn", "BSIPA|^4.3.0", "TestDepend1|^2.0.1", "TestDepend2|^1.0.0"),
                ConflictsWith =
                    MockTaskItem.FromDictString("ConflictsWith", "TestConflict1|^2.0.1", "TestConflict2|^1.0.0"),
                Files         = new string[] { "Libs/TestLib1.dll", "Libs/TestLib2.dll" },
                Donate        = "http://donate.com",
                ProjectHome   = "http://project.home",
                ProjectSource = "http://project.source",
                PluginHint    = "Namespace.Plugin.Type",
                RequiresBsipa = false,
                TargetPath    = targetPath
            };

            Assert.IsTrue(task.Execute());
            BsipaManifest manifest = BsipaManifest.FromJson(File.ReadAllText(targetPath));

            TestManifest(task, manifest);
            Assert.AreEqual(task.Donate, manifest.Donate);
            Assert.AreEqual(task.ProjectHome, manifest.ProjectHome);
            Assert.AreEqual(task.ProjectSource, manifest.ProjectSource);
            Assert.AreEqual(task.PluginHint, manifest.PluginHint);
        }
Example #2
0
        public void Valid_WithBaseManifest_DependsOnSingle()
        {
            Directory.CreateDirectory(OutputPath);
            string basePath      = Path.Combine(Data, "manifest.json");
            int    baseDepends   = 2;
            int    baseConflicts = 0;
            string targetPath    = Path.Combine(OutputPath, nameof(Valid_WithBaseManifest_DependsOnSingle) + ".json");
            var    task          = new GenerateManifest()
            {
                Id          = "TestPlugin",
                Name        = "Test Plugin",
                Author      = "Zingabopp",
                Version     = "1.0.0",
                GameVersion = "1.14.0",
                Description = "Description of a test plugin.",
                DependsOn   =
                    MockTaskItem.FromDictString("DependsOn", "BSIPA|^4.3.0", "TestDepend1|^2.0.1", "TestDepend2|^1.0.0"),
                ConflictsWith =
                    MockTaskItem.FromDictString("ConflictsWith", "TestConflict1|^2.0.1", "TestConflict2|^1.0.0"),
                RequiresBsipa    = true,
                BaseManifestPath = basePath,
                TargetPath       = targetPath
            };

            Assert.IsTrue(task.Execute());
            BsipaManifest manifest = BsipaManifest.FromJson(File.ReadAllText(targetPath));

            TestManifest(task, manifest, baseDepends, baseConflicts);
        }
Example #3
0
        public void Valid_FullyGenerated_FilesStr()
        {
            Directory.CreateDirectory(OutputPath);
            string targetPath = Path.Combine(OutputPath, nameof(Valid_FullyGenerated_FilesStr) + ".json");
            var    task       = new GenerateManifest()
            {
                Id            = "TestPlugin",
                Name          = "Test Plugin",
                Author        = "Zingabopp",
                Version       = "1.0.0",
                GameVersion   = "1.14.0",
                Description   = "Description of a test plugin.",
                Files         = new string[] { "Libs/TestLib1.dll;Libs/TestLib2.dll" },
                RequiresBsipa = false,
                TargetPath    = targetPath
            };

            Assert.IsTrue(task.Execute());
            BsipaManifest manifest = BsipaManifest.FromJson(File.ReadAllText(targetPath));

            TestManifest(task, manifest);
        }
Example #4
0
        public void Valid_FullyGenerated_DependsOnArray()
        {
            Directory.CreateDirectory(OutputPath);
            string targetPath = Path.Combine(OutputPath, nameof(Valid_FullyGenerated_DependsOnArray) + ".json");
            var    task       = new GenerateManifest()
            {
                Id          = "TestPlugin",
                Name        = "Test Plugin",
                Author      = "Zingabopp",
                Version     = "1.0.0",
                GameVersion = "1.14.0",
                Description = "Description of a test plugin.",
                DependsOn   =
                    MockTaskItem.FromDictString("DependsOn", "BSIPA|^4.3.0", "TestDepend1|^2.0.1", "TestDepend2|^1.0.0"),
                RequiresBsipa = true,
                TargetPath    = targetPath
            };

            Assert.IsTrue(task.Execute());
            BsipaManifest manifest = BsipaManifest.FromJson(File.ReadAllText(targetPath));

            TestManifest(task, manifest);
        }
Example #5
0
        private BsipaManifest MakeManifest()
        {
            BsipaManifest manifest;

            if (!string.IsNullOrWhiteSpace(BaseManifestPath))
            {
                string manifestPath = Path.GetFullPath(BaseManifestPath);
                if (File.Exists(manifestPath))
                {
                    try
                    {
                        manifest = BsipaManifest.FromJson(File.ReadAllText(manifestPath));
                    }
                    catch (Exception ex)
                    {
                        throw new IOException($"Failed to read JSON at '${manifestPath}': {ex.Message}");
                    }
                }
                else
                {
                    throw new ArgumentException($"A BaseManifestFile '${manifestPath}' does not exist."
                                                , nameof(BaseManifestPath));
                }
            }
            else
            {
                manifest = new BsipaManifest();
            }
            if (string.IsNullOrWhiteSpace(TargetPath))
            {
                TargetPath = "manifest.json";
            }
            SetRequiredProperties(manifest);
            SetOptionalProperties(manifest);
            return(manifest);
        }