예제 #1
0
        public void Latest_recent_is_last()
        {
            var list = new RecentlyUsedList();

            list.Add(25);
            list.Add(32);
            Assert.AreEqual(25, list.Last());
        }
예제 #2
0
        public void Most_recent_is_first()
        {
            var list = new RecentlyUsedList();

            list.Add(25);
            list.Add(32);
            Assert.AreEqual(32, list.First());
        }
예제 #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));
        }
예제 #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));
        }
예제 #5
0
        public void Add_WhenCalledTwiceWithSameValues_ShouldOnlyAddOne()
        {
            var list = new RecentlyUsedList <int>();

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

            list.Count.ShouldBe(1);
        }
예제 #6
0
        public void Add_WhenCalledTwiceWithDifferentValues_ShouldContainTwoItems()
        {
            var list = new RecentlyUsedList <int>();

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

            list.Count.ShouldBe(2);
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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");
    }
예제 #12
0
        public void Add_WhenCalledOnce_ShouldReturnAddedItem()
        {
            var list = new RecentlyUsedList <int>();

            list.Add("someId", 123);

            list[0].Value.ShouldBe(123);
        }
예제 #13
0
        public void Add_AddsAValue_ShouldIncrementTheCount()
        {
            _testee.Add(EnteredNumber);

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