Пример #1
0
        public void KeysISorted()
        {
            ISorted <string> keys = dict.Keys;

            Assert.IsTrue(keys.IsReadOnly);
            Assert.AreEqual("R", keys.FindMin());
            Assert.AreEqual("T", keys.FindMax());
            Assert.IsTrue(keys.Contains("S"));
            Assert.AreEqual(3, keys.Count);
            // This doesn't hold, maybe because the dict uses a special key comparer?
            // Assert.IsTrue(keys.SequencedEquals(new WrappedArray<string>(new string[] { "R", "S", "T" })));
            Assert.IsTrue(keys.UniqueItems().All(delegate(String s) {
                return(s == "R" || s == "S" || s == "T");
            }));
            Assert.IsTrue(keys.All(delegate(String s) {
                return(s == "R" || s == "S" || s == "T");
            }));
            Assert.IsFalse(keys.Exists(delegate(String s) {
                return(s != "R" && s != "S" && s != "T");
            }));
            String res;

            Assert.IsTrue(keys.Find(delegate(String s) {
                return(s == "R");
            }, out res));
            Assert.AreEqual("R", res);
            Assert.IsFalse(keys.Find(delegate(String s) {
                return(s == "Q");
            }, out res));
            Assert.AreEqual(null, res);
        }