public void AvailableKeys_Array_NotInScheme() { var root = new PDictionary(); root.Add("foo", new PArray()); var available = PListScheme.AvailableKeys(root["foo"], PListScheme.Match(root, PListScheme.Empty)); Assert.IsNull(available, "#1"); }
public void AvailableKeys_Dictionary() { var scheme = Load(@" <PListScheme> <Key name = ""keyname"" type = ""Dictionary"" /> </PListScheme>"); var value = new PDictionary(); var root = new PDictionary(); root.Add("keyname", value); var available = PListScheme.AvailableKeys(value, PListScheme.Match(root, scheme)); Assert.AreEqual(1, available.Count, "#1"); Assert.AreEqual(PString.Type, available [0].Type, "#2"); }
public void AvailableKeys_NumberArray() { var scheme = Load(@" <PListScheme> <Key name = ""keyname"" type = ""Array"" arrayType = ""Number"" > <Value name = ""1"" /> <Value name = ""2"" /> <Value name = ""3"" /> </Key> </PListScheme>"); var key = scheme.GetKey("keyname"); var value = new PArray(); var root = new PDictionary(); root.Add(key.Identifier, value); var available = PListScheme.AvailableKeys(value, PListScheme.Match(root, scheme)); Assert.AreEqual(3, available.Count, "#1"); // We can create '2' or '3', but not '1' value.Add(new PNumber(1)); available = PListScheme.AvailableKeys(value, PListScheme.Match(root, scheme)); Assert.AreEqual(2, available.Count, "#2"); Assert.IsFalse(available.Any(v => v.Identifier == "1"), "#3"); // We can only create '3' value.Add(new PNumber(2)); available = PListScheme.AvailableKeys(value, PListScheme.Match(root, scheme)); Assert.AreEqual(1, available.Count, "#4"); Assert.IsTrue(available.Any(v => v.Identifier == "3"), "#5"); value.Add(new PNumber(3)); available = PListScheme.AvailableKeys(value, PListScheme.Match(root, scheme)); Assert.AreEqual(0, available.Count, "#4"); }