2025-01-08 20:47:15 +01:00
|
|
|
using Claunia.PropertyList;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2025-08-07 22:31:12 +01:00
|
|
|
namespace plistcil.test;
|
|
|
|
|
|
|
|
|
|
public class NSStringTests
|
2025-01-08 20:47:15 +01:00
|
|
|
{
|
2025-08-07 22:31:12 +01:00
|
|
|
const string START_TOKEN = "<string>";
|
|
|
|
|
const string END_TOKEN = "</string>";
|
2025-01-08 20:47:15 +01:00
|
|
|
|
2025-08-07 22:31:12 +01:00
|
|
|
[InlineData("abc", "abc")]
|
|
|
|
|
[InlineData("a>b", "a>b")]
|
|
|
|
|
[InlineData("a<b", "a<b")]
|
|
|
|
|
[InlineData("a&b", "a&b")]
|
|
|
|
|
[Theory]
|
|
|
|
|
public void Content_IsEscaped(string value, string content)
|
|
|
|
|
{
|
|
|
|
|
var element = new NSString(value);
|
|
|
|
|
string xml = element.ToXmlPropertyList();
|
2025-01-08 20:47:15 +01:00
|
|
|
|
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-01-08 20:47:15 +01:00
|
|
|
|
2025-08-07 22:31:12 +01:00
|
|
|
Assert.Equal(content, actualContent);
|
2025-01-08 20:47:15 +01:00
|
|
|
}
|
2025-08-07 22:31:12 +01:00
|
|
|
}
|