public void CanSerializeComplexPlist() { // Arrange var fileContent = File.ReadAllText("Data/SerializeResult.plist"); var expected = XElement.Parse(fileContent).ToString(SaveOptions.DisableFormatting); var value = new Dictionary <string, object> { { "CFBundleShortVersionString", "1.1.3" }, { "CFBundleVersion", "1.1.3+Branch.master.Sha.41e4b956b644d0a30e8aa28a6cb6509d99e81031" }, { "LSRequiresIPhoneOS", true }, { "MinimumOSVersion", "8.0" }, { "UIDeviceFamily", new[] { 1, 2 } }, { "UILaunchStoryboardName", "LaunchScreen" }, { "UIRequiredDeviceCapabilities", new[] { "armv7" } }, { "UISupportedInterfaceOrientations", new[] { "UIInterfaceOrientationPortrait", "UIInterfaceOrientationPortraitUpsideDown" } }, { "UISupportedInterfaceOrientations~ipad", new[] { "UIInterfaceOrientationPortrait", "UIInterfaceOrientationPortraitUpsideDown" } }, { "CFBundleName", "Demo App" }, { "CFBundleIdentifier", "com.democom.demo" }, { "CFBundleDisplayName", "Demo" }, { "NSLocationAlwaysUsageDescription", "This app needs your current location." }, { "UIBackgroundModes", new[] { "location" } }, { "CFBundleIconFiles", new[] { "*****@*****.**", "Icon-72.png", "*****@*****.**", "Icon-76.png", "*****@*****.**", "Icon-Small-40.png", "*****@*****.**" } }, { "UIStatusBarHidden", true }, { "UIStatusBarHidden~ipad", true } }; // Act var doc = PlistConvert.SerializeDocument(value); doc.FirstNode.Remove(); // Assert Assert.Equal(expected, doc.ToString(SaveOptions.DisableFormatting)); }
public void SerializerAddDocHeader() { var doc = PlistConvert.SerializeDocument(new Dictionary <string, object> { { "k1", 1 } }); string result; using (var sw = new MemoryStream()) using (var strw = new StreamWriter(sw)) { doc.Save(strw, SaveOptions.DisableFormatting); result = Encoding.UTF8.GetString(sw.ToArray()); } Assert.StartsWith("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">", result); }