コード例 #1
0
        public void OrderAndDuplicates()
        {
            var c = new MostRecentlyUsedCollection <string> {
                "a", "b", "c"
            };

            c.SequenceShouldEqual(new [] { "c", "b", "a" });

            c.Add("b");
            c.SequenceShouldEqual(new [] { "b", "c", "a" });

            c.Add("b");
            c.SequenceShouldEqual(new [] { "b", "c", "a" });
        }
コード例 #2
0
        public void Load()
        {
            var items = new [] { "a", "b", "c", "d" };
            var c     = new MostRecentlyUsedCollection <string> ();

            c.Load(items);
            c.SequenceShouldEqual(items);
        }
コード例 #3
0
        public void Validation()
        {
            var validItems = new [] { "a", "b", "c" };

            var c = new MostRecentlyUsedCollection <string> (
                itemValidationDelegate: i => validItems.Contains(i));

            c.Load(new [] { "a", "b", "c", "d" });
            c.SequenceShouldEqual(validItems);

            c.Clear();
            c.Count.ShouldEqual(0);

            c.Add("d");
            c.Count.ShouldEqual(0);

            // ensure even if we make no inserts, we still validate the rest
            c.Load(new [] { "a", "b", "c", "d" });
            validItems = new [] { "a" };
            c.Add("a");
            c.SequenceShouldEqual(new [] { "a" });
        }