Files
plist-cil/plist-cil.test/NSStringTests.cs

28 lines
845 B
C#
Raw Normal View History

using Claunia.PropertyList;
using Xunit;
2025-08-07 22:31:12 +01:00
namespace plistcil.test;
public class NSStringTests
{
2025-08-07 22:31:12 +01:00
const string START_TOKEN = "<string>";
const string END_TOKEN = "</string>";
2025-08-07 22:31:12 +01:00
[InlineData("abc", "abc")]
[InlineData("a>b", "a&gt;b")]
[InlineData("a<b", "a&lt;b")]
[InlineData("a&b", "a&amp;b")]
[Theory]
public void Content_IsEscaped(string value, string content)
{
var element = new NSString(value);
string xml = element.ToXmlPropertyList();
2025-08-07 22:31:12 +01:00
// Strip the leading and trailing data, so we just get the string element itself
int start = xml.IndexOf(START_TOKEN) + START_TOKEN.Length;
int end = xml.IndexOf(END_TOKEN);
string actualContent = xml.Substring(start, end - start);
2025-08-07 22:31:12 +01:00
Assert.Equal(content, actualContent);
}
2025-08-07 22:31:12 +01:00
}