Exemple #1
0
        public void Can_check_that_an_item_is_in_the_set()
        {
            var set = new LeastRecentlyUsedSet<string>();
            set.Write((add, remove) =>
            {
                add("blah");
                add("foo");
                add("bar");
            });

            Assert.True(set.Contains("foo"));
        }
Exemple #2
0
        public void Can_remove_items()
        {
            var set = new LeastRecentlyUsedSet<string>();
            set.Write((add,remove) =>
            {
                add("blah");
                add("foo");
                add("bar");
                remove("foo");
            });

            Assert.False(set.Contains("foo"));
        }
Exemple #3
0
        public void Can_check_that_an_item_is_in_the_set()
        {
            var set = new LeastRecentlyUsedSet <string>();

            set.Write((add, remove) =>
            {
                add("blah");
                add("foo");
                add("bar");
            });

            Assert.True(set.Contains("foo"));
        }
Exemple #4
0
        public void Can_remove_items()
        {
            var set = new LeastRecentlyUsedSet <string>();

            set.Write((add, remove) =>
            {
                add("blah");
                add("foo");
                add("bar");
                remove("foo");
            });

            Assert.False(set.Contains("foo"));
        }
Exemple #5
0
        public void When_selecting_what_to_remove_from_set_will_select_oldest_items()
        {
            var set = new LeastRecentlyUsedSet<string>(10);

            set.Write((add, remove) =>
            {
                for (int i = 0; i < 20; i++)
                {
                    add(i.ToString());
                }
            }); 
            for (int i = 10; i < 20; i++)
            {
                Assert.True(set.Contains(i.ToString()));
            }
        }
Exemple #6
0
        public void Cannot_have_more_than_limited_amount_in_set()
        {
            var set = new LeastRecentlyUsedSet<string>(10);

            set.Write((add, remove) =>
            {
                for (int i = 0; i < 20; i++)
                {
                    add(i.ToString());
                }
            }); 

            var length = set.Count();

            Assert.Equal(10, length);
        }
Exemple #7
0
        public void When_selecting_what_to_remove_from_set_will_select_oldest_items()
        {
            var set = new LeastRecentlyUsedSet <string>(10);

            set.Write((add, remove) =>
            {
                for (int i = 0; i < 20; i++)
                {
                    add(i.ToString());
                }
            });
            for (int i = 10; i < 20; i++)
            {
                Assert.True(set.Contains(i.ToString()));
            }
        }
Exemple #8
0
        public void Cannot_have_more_than_limited_amount_in_set()
        {
            var set = new LeastRecentlyUsedSet <string>(10);

            set.Write((add, remove) =>
            {
                for (int i = 0; i < 20; i++)
                {
                    add(i.ToString());
                }
            });

            var length = set.Count();

            Assert.Equal(10, length);
        }
Exemple #9
0
        public void Can_iterate_items()
        {
            var set = new LeastRecentlyUsedSet<string>();

            set.Write((add, remove) =>
            {
                add("blah");
                add("foo");
                add("bar");
            });

            var array = set.OrderBy(x => x).ToArray();//iterate & order

            Assert.Equal("bar", array[0]);
            Assert.Equal("blah", array[1]);
            Assert.Equal("foo", array[2]);
        }
Exemple #10
0
        public void Can_iterate_items()
        {
            var set = new LeastRecentlyUsedSet <string>();

            set.Write((add, remove) =>
            {
                add("blah");
                add("foo");
                add("bar");
            });

            var array = set.OrderBy(x => x).ToArray();//iterate & order

            Assert.Equal("bar", array[0]);
            Assert.Equal("blah", array[1]);
            Assert.Equal("foo", array[2]);
        }