Exemplo n.º 1
0
        public void Latest_recent_is_last()
        {
            var list = new RecentlyUsedList();

            list.Add(25);
            list.Add(32);
            Assert.AreEqual(25, list.Last());
        }
Exemplo n.º 2
0
        public void Most_recent_is_first()
        {
            var list = new RecentlyUsedList();

            list.Add(25);
            list.Add(32);
            Assert.AreEqual(32, list.First());
        }
Exemplo n.º 3
0
        public void Add_WhenItemAdded_ShouldReturnItFirst()
        {
            var list = new RecentlyUsedList <int>();

            list.Add("someId", 123);
            list.Add("someId2", 124);

            list[0].ShouldBe(("someId2", 124));
        }
Exemplo n.º 4
0
        public void Add_WhenCalledTwiceWithTheSameId_ShoudContainSecondItem()
        {
            var list = new RecentlyUsedList <int>();

            list.Add("someId", 123);
            list.Add("someId", 124);

            list[0].ShouldBe(("someId", 124));
        }
Exemplo n.º 5
0
        public void Add_WhenCalledTwiceWithSameValues_ShouldOnlyAddOne()
        {
            var list = new RecentlyUsedList <int>();

            list.Add("someId", 123);
            list.Add("someId", 123);

            list.Count.ShouldBe(1);
        }
Exemplo n.º 6
0
        public void Add_WhenCalledTwiceWithDifferentValues_ShouldContainTwoItems()
        {
            var list = new RecentlyUsedList <int>();

            list.Add("someId", 123);
            list.Add("secondId", 123);

            list.Count.ShouldBe(2);
        }
Exemplo n.º 7
0
        public void Items_are_unique()
        {
            var list = new RecentlyUsedList();

            list.Add(25);
            list.Add(67);
            list.Add(25);
            list.Add(25);
            Assert.AreEqual(25, list.Index(0));
            Assert.AreEqual(67, list.Index(1));
        }
Exemplo n.º 8
0
        public void duplicate_insertions_are_moved()
        {
            var list = new RecentlyUsedList();

            list.Add(25);
            list.Add(67);
            Assert.AreEqual(67, list.Index(0));
            Assert.AreEqual(25, list.Index(1));
            list.Add(25);
            Assert.AreEqual(25, list.Index(0));
            Assert.AreEqual(67, list.Index(1));
        }
Exemplo n.º 9
0
        public void Capacity_set_in_constructor_item_dropped_on_overflow()
        {
            var list = new RecentlyUsedList(3);

            list.Add(33);
            list.Add(67);
            list.Add(87);
            list.Add(55);
            list.Add(88);
            Assert.AreEqual(87, list.Index(0));
            Assert.AreEqual(67, list.Index(1));
            Assert.AreEqual(33, list.Index(2));
        }
Exemplo n.º 10
0
        public void Items_accessed_by_index()
        {
            var list = new RecentlyUsedList();

            list.Add(25);
            list.Add(32);
            list.Add(67);
            list.Add(13);
            Assert.AreEqual(13, list.Index(0));
            Assert.AreEqual(67, list.Index(1));
            Assert.AreEqual(32, list.Index(2));
            Assert.AreEqual(25, list.Index(3));
        }
    public void Add_WhenFirstItemAdded_ReturnsTheAddedItemId()
    {
        var list = new RecentlyUsedList <int>();

        list.Add("someId", 123);

        list[0].Id.ShouldBe("someId");
    }
Exemplo n.º 12
0
        public void Add_WhenCalledOnce_ShouldReturnAddedItem()
        {
            var list = new RecentlyUsedList <int>();

            list.Add("someId", 123);

            list[0].Value.ShouldBe(123);
        }
Exemplo n.º 13
0
        public void Add_AddsAValue_ShouldIncrementTheCount()
        {
            _testee.Add(EnteredNumber);

            _testee.Count.Should().Be(1);
        }