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 InvalidPropertiesRequiresBsipa_ThrowsException()
        {
            Directory.CreateDirectory(OutputPath);
            string         targetPath = Path.Combine(OutputPath, nameof(InvalidProperties_ThrowsException) + ".json");
            MockTaskLogger logger     = new MockTaskLogger(nameof(GenerateManifest));
            var            task       = new GenerateManifest()
            {
                RequiresBsipa = true,
                TargetPath    = targetPath,
                Logger        = logger,
                DependsOn     =
                    MockTaskItem.FromDictString("DependsOn", "BSIPA|^4.3.0"),
            };

            Assert.IsFalse(task.Execute());
            var logEntry = logger.LogEntries.First();

            Console.Write(logEntry.Message);
            var exception = logEntry.Exception as ManifestValidationException;

            Assert.IsNotNull(exception);
            var props = exception.InvalidProperties;

            Assert.IsTrue(props.Any(p => p == nameof(GenerateManifest.Id)));
            Assert.IsTrue(props.Any(p => p == nameof(GenerateManifest.Name)));
            Assert.IsTrue(props.Any(p => p == nameof(GenerateManifest.Author)));
            Assert.IsTrue(props.Any(p => p == nameof(GenerateManifest.Version)));
            Assert.IsTrue(props.Any(p => p == nameof(GenerateManifest.GameVersion)));
            Assert.IsTrue(props.Any(p => p == nameof(GenerateManifest.Description)));
        }
Example #3
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 #4
0
        public void Generate()
        {
            var task = new GenerateManifest {
                BuildEngine      = engine,
                DestinationFile  = temp,
                PackageName      = "com.test.app",
                ApplicationClass = "My.Namespace.App, MyAssembly",
                ActivityName     = "xamarin.android.lite.MainActivity",
                VersionCode      = "12",
                VersionName      = "2.0.0",
                AppTitle         = "MyApp",
                ActivityTitle    = "MyActivity",
            };

            Assert.IsTrue(task.Execute(), "Execute failed!");

            using (var stream = File.OpenRead(temp)) {
                var manifest = AndroidManifest.Read(stream);
                var xml      = @"<manifest xmlns:android=""http://schemas.android.com/apk/res/android"" android:versionCode=""12"" android:versionName=""2.0.0"" package=""com.test.app"" platformBuildVersionCode=""27"" platformBuildVersionName=""8.1.0"">
  <uses-sdk android:minSdkVersion=""19"" android:targetSdkVersion=""27"" />
  <uses-permission android:name=""android.permission.INTERNET"" />
  <uses-permission android:name=""android.permission.READ_EXTERNAL_STORAGE"" />
  <uses-permission android:name=""android.permission.WRITE_EXTERNAL_STORAGE"" />
  <uses-permission android:name=""android.permission.ACCESS_NETWORK_STATE"" />
  <uses-permission android:name=""android.permission.BATTERY_STATS"" />
  <uses-permission android:name=""android.permission.CAMERA"" />
  <uses-permission android:name=""android.permission.FLASHLIGHT"" />
  <uses-permission android:name=""android.permission.ACCESS_COARSE_LOCATION"" />
  <uses-permission android:name=""android.permission.ACCESS_FINE_LOCATION"" />
  <uses-permission android:name=""android.permission.VIBRATE"" />
  <uses-feature android:name=""android.hardware.location"" android:required=""false"" />
  <uses-feature android:name=""android.hardware.location.gps"" android:required=""false"" />
  <uses-feature android:name=""android.hardware.location.network"" android:required=""false"" />
  <application android:label=""MyApp"" android:icon=""2130903040"" android:name=""android.app.Application"" android:debuggable=""true"" android:allowBackup=""true"">
    <meta-data android:name=""Xamarin.Android.Lite.Application"" android:value=""My.Namespace.App, MyAssembly"" />
    <activity android:theme=""2131493263"" android:label=""MyActivity"" android:icon=""2130903040"" android:name=""xamarin.android.lite.MainActivity"" android:configChanges=""1152"">
      <intent-filter>
        <action android:name=""android.intent.action.MAIN"" />
        <category android:name=""android.intent.category.LAUNCHER"" />
      </intent-filter>
    </activity>
    <service android:name=""md5dcb6eccdc824e0677ffae8ccdde42930.KeepAliveService"" />
    <receiver android:label=""Essentials Battery Broadcast Receiver"" android:name=""md5d630c3d3bfb5f5558520331566132d97.BatteryBroadcastReceiver"" android:enabled=""true"" android:exported=""false"" />
    <receiver android:label=""Essentials Connectivity Broadcast Receiver"" android:name=""md5d630c3d3bfb5f5558520331566132d97.ConnectivityBroadcastReceiver"" android:enabled=""true"" android:exported=""false"" />
    <receiver android:label=""Essentials Power Broadcast Receiver"" android:name=""md5d630c3d3bfb5f5558520331566132d97.PowerBroadcastReceiver"" android:enabled=""true"" android:exported=""false"" />
    <receiver android:name=""md51558244f76c53b6aeda52c8a337f2c37.PowerSaveModeBroadcastReceiver"" android:enabled=""true"" android:exported=""false"" />
    <provider android:name=""mono.MonoRuntimeProvider"" android:exported=""false"" android:authorities=""com.test.app.mono.MonoRuntimeProvider.__mono_init_"" android:initOrder=""2147483647"" />
    <receiver android:name=""mono.android.Seppuku"">
      <intent-filter>
        <action android:name=""mono.android.intent.action.SEPPUKU"" />
        <category android:name=""mono.android.intent.category.SEPPUKU.com.test.app"" />
      </intent-filter>
    </receiver>
  </application>
</manifest>";
                Assert.AreEqual(xml, manifest.Document.ToString());
            }
        }
Example #5
0
 public void TestManifest(GenerateManifest task, BsipaManifest manifest, int baseDepends = 0, int baseConflicts = 0)
 {
     Assert.AreEqual(task.Id, manifest.Id);
     Assert.AreEqual(task.Name, manifest.Name);
     Assert.AreEqual(task.Author, manifest.Author);
     Assert.AreEqual(task.Version, manifest.Version);
     Assert.AreEqual(task.GameVersion, manifest.GameVersion);
     Assert.AreEqual(task.Description, manifest.Description);
     Assert.AreEqual(task.Icon, manifest.Icon);
     CompareDictionary(ParseUtil.ParseModIds(task.DependsOn, null, "DependsOn"), manifest.DependsOn, baseDepends);
     CompareDictionary(ParseUtil.ParseModIds(task.ConflictsWith, null, "ConflictsWith"), manifest.ConflictsWith, baseConflicts);
     CompareStringArrays(ParseUtil.ParseStringArray(task.Files), manifest.Files, 0);
 }
Example #6
0
        public void AllBase_NoOverwrite()
        {
            Directory.CreateDirectory(OutputPath);
            string basePath   = Path.Combine(Data, "Original-all.json");
            string targetPath = Path.Combine(OutputPath, nameof(AllBase_NoOverwrite) + ".json");

            Console.WriteLine($"Writing output to '{Path.GetFullPath(targetPath)}'");
            var task = new GenerateManifest()
            {
                BaseManifestPath = basePath,
                TargetPath       = targetPath
            };

            Assert.IsTrue(task.Execute());
        }
Example #7
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 #8
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 #9
0
        public void MergeAllTest()
        {
            Directory.CreateDirectory(OutputPath);
            string basePath   = Path.Combine(Data, "overwrite.json");
            string targetPath = Path.Combine(OutputPath, nameof(MergeAllTest) + ".json");

            Console.WriteLine($"Writing output to '{Path.GetFullPath(targetPath)}'");
            var task = new GenerateManifest()
            {
                Id          = "New-ID",
                Name        = "New-Name",
                Author      = "New-Author",
                Version     = "1.0.0-New",
                GameVersion = "1.14.0-New",
                Description = "New-Description",
                Files       = new string[] { "Libs/New-File1.dll", "Libs/New-File2.dll" },
                DependsOn   =
                    MockTaskItem.FromDictString("DependsOn", "BSIPA|^NewVersion", "New-Depend|^2.0.1", "TestDepend2|^1.0.0"),
                ConflictsWith =
                    MockTaskItem.FromDictString("ConflictsWith", "BeatSaberPlus|^NewVersion", "New-Conflict|^1.0.0"),

                LoadBefore       = new string[] { "Libs/New-LoadBefore1.dll", "Libs/New-LoadBefore2.dll" },
                LoadAfter        = new string[] { "Libs/New-LoadAfter1.dll", "Libs/New-LoadAfter2.dll" },
                Icon             = "New-Icon.png",
                Donate           = "http://New-donate.com",
                ProjectHome      = "http://New-project.home",
                ProjectSource    = "http://New-project.source",
                Features         = "{ \"New-Feature\" : { \"name\" : \"New-feature-name\" } }",
                Misc             = "{ \"Other-Misc\" : { \"name\" : \"New-Misc-name\" } }",
                PluginHint       = "Namespace.Plugin.Type",
                RequiresBsipa    = true,
                BaseManifestPath = basePath,
                TargetPath       = targetPath
            };

            Assert.IsTrue(task.Execute());
        }