コード例 #1
0
        public void SaveTest()
        {
            if (File.Exists(SaveTestPath))
            {
                File.Delete(SaveTestPath);
            }

            var originalManifest = AndroidAppManifest.Create("com.test.test", "Test Label");

            originalManifest.MinSdkVersion   = 14;
            originalManifest.VersionName     = "3.3";
            originalManifest.VersionCode     = 2;
            originalManifest.ApplicationIcon = "@drawable/icon";

            var cake = Substitute.For <ICakeContext> ();

            cake.SerializeAppManifest(SaveTestPath, originalManifest);

            var modifiedManifest = cake.DeserializeAppManifest(new FilePath(SaveTestPath));

            modifiedManifest.PackageName.Should().Be(originalManifest.PackageName);
            modifiedManifest.ApplicationLabel.Should().Be(originalManifest.ApplicationLabel);
            modifiedManifest.ApplicationIcon.Should().Be(originalManifest.ApplicationIcon);
            modifiedManifest.MinSdkVersion.Should().Be(originalManifest.MinSdkVersion);
            modifiedManifest.VersionName.Should().Be("3.3");
            modifiedManifest.VersionCode.Should().Be(2);
        }
コード例 #2
0
        public void EnsureUsesPermissionElementOrder()
        {
            var versions = new AndroidVersions(new AndroidVersion [0]);
            var manifest = AndroidAppManifest.Create("com.xamarin.test", "Xamarin Test", versions);

            manifest.SetAndroidPermissions(new string[] { "FOO" });
            var sb = new StringBuilder();

            using (var writer = XmlWriter.Create(sb)) {
                manifest.Write(writer);
            }

            var doc = XDocument.Parse(sb.ToString());
            var app = doc.Element("manifest").Element("application");

            Assert.IsNotNull(app, "Application element should exist");
            Assert.IsFalse(app.ElementsAfterSelf().Any(x => x.Name == "uses-permission"));
            Assert.IsTrue(app.ElementsBeforeSelf().Any(x => x.Name == "uses-permission"));
        }