public void ShouldInsertValuesIfFourIsAddedToIndexZeroAndFiveIsAddedToIndexOneAndReturnCountTwo()
 {
     RecentlyUsedList<int> nums = new RecentlyUsedList<int>(5);
     nums.AddItem(4);
     nums.AddItem(5);
     int count = nums.NoOfElements();
     Assert.AreEqual(2, count, "Expected value is 2");
     Assert.AreEqual(5, nums[0], "Expected value is 5");
     Assert.AreEqual(4, nums[1], "Expected value is 4");
 }
 public void ShouldGiveSixFiveFourIfFourIsAddedToIndexZeroAndFiveIsAddedToIndexOneAndSixIsAddedToIndexTwoAndReturnCountThree()
 {
     RecentlyUsedList<int> nums = new RecentlyUsedList<int>(5);
     nums.AddItem(4);
     nums.AddItem(5);
     nums.AddItem(6);
     int count = nums.NoOfElements();
     Assert.AreEqual(3, count, "Expected value is 3");
     Assert.AreEqual(6, nums[0], "Expected value is 6");
     Assert.AreEqual(5, nums[1], "Expected value is 5");
     Assert.AreEqual(4, nums[2], "Expected value is 4");
 }
        public void ShouldReturn_c_When_c_IsAddedLast()
        {
            RecentlyUsedList<string> ListObject = new RecentlyUsedList<string>(5);

            ListObject.AddItem("Mohit");
            ListObject.AddItem("Raj");
            ListObject.AddItem("Atrey");

            var item = ListObject[0];

            Assert.AreEqual("Atrey", item, "The most recently added item is not the first item.");
        }
 public void ShouldGiveFiveAtZeroIndexIfFiveIsAddedToIndexFourAndItIsAlreadyAtIndexOneAndReturnFour()
 {
     RecentlyUsedList<int> nums = new RecentlyUsedList<int>(5);
     nums.AddItem(4);
     nums.AddItem(5);
     nums.AddItem(6);
     nums.AddItem(7);
     nums.AddItem(5);
     int count = nums.NoOfElements();
     Assert.AreEqual(4, count, "Expected value is 4");
     Assert.AreEqual(5, nums[0], "Expected value is 5");
     Assert.AreEqual(4, nums[3], "Expected value is 4");
 }
        public void ShouldReturnEightWhenItemAtIndexOneIsCalled_AndEightShouldBeTheFirstElement()
        {
            RecentlyUsedList<int> ListObject = new RecentlyUsedList<int>(5);

            ListObject.AddItem(12);
            ListObject.AddItem(8);
            ListObject.AddItem(5);

            var item = ListObject[1];

            Assert.AreEqual(8, item, "8 is not at the first index.");
            Assert.AreEqual(8, ListObject[0], "8 is not the first item.");
        }
        public void ShouldReturnThreeWhenCountItemsIsCalledAfterEightIsAddedAgainAndEightShouldBeTheFirstElement()
        {
            RecentlyUsedList<char> ListObject = new RecentlyUsedList<char>(5);

            ListObject.AddItem('m');
            ListObject.AddItem('a');
            ListObject.AddItem('c');
            ListObject.AddItem('a');

            int countItems = ListObject.CountItems();

            Assert.AreEqual(3, countItems, "The size of list is not Three");
            Assert.AreEqual('a', ListObject[0], "a is not the first item.");
        }
 public void ShouldGiveFourIfFourIsAddedToIndexZeroAndReturnCountOne()
 {
     RecentlyUsedList<int> nums = new RecentlyUsedList<int>(5);
     nums.AddItem(4);
     int count = nums.NoOfElements();
     Assert.AreEqual(1, count, "Expected value is 1");
     Assert.AreEqual(4, nums[0], "Expected value is 4");
 }
 public void ShouldRemoveFourFromZeroIndexIfNineIsAddedToIndexFiveAndReturnCountFive()
 {
     RecentlyUsedList<int> nums = new RecentlyUsedList<int>(5);
     nums.AddItem(4);
     nums.AddItem(5);
     nums.AddItem(6);
     nums.AddItem(7);
     nums.AddItem(8);
     nums.AddItem(9);
     int count = nums.NoOfElements();
     Assert.AreEqual(5, count, "Expected value is 5");
     Assert.AreEqual(9, nums[0], "Expected value is 9");
     Assert.AreEqual(5, nums[4], "Expected value is 5");
 }
        public void ShouldReturnAtreyAsFirstItemAndEightAsLastItemIfAtreyIsAddedAfterListSizeIsFull()
        {
            RecentlyUsedList<int> ListObject = new RecentlyUsedList<int>(5);

            ListObject.AddItem(11);
            ListObject.AddItem(8);
            ListObject.AddItem(6);
            ListObject.AddItem(4);
            ListObject.AddItem(13);
            ListObject.AddItem(32);

            var firstItem = ListObject[0];
            var lastItem = ListObject[4];
            int countItems = ListObject.CountItems();

            Assert.AreEqual(32,firstItem , "The First item is not 32.");
            Assert.AreEqual(8, lastItem, "The last item is not 8.");
            Assert.AreEqual(5, countItems, "The size of list is not five");
        }
        static void Main(string[] args)
        {
            //RecentlyUsedList rul = new RecentlyUsedList();
            //rul.AddItem("Mohit");
            //rul.AddItem(1);
            //rul.AddItem('c');
            //rul.showList();
            //Console.WriteLine(rul.SearchByIndex(1));
            //rul.AddItem(1);
            //rul.showList();
            RecentlyUsedList<int> ListObject = new RecentlyUsedList<int>(5);

            ListObject.AddItem(4);
            ListObject.AddItem(8);
            ListObject.AddItem(3);
            ListObject.AddItem(4);
            ListObject.AddItem(2);
            ListObject.AddItem(1);

            ListObject.ShowList();
            Console.ReadKey();
        }
 public void ShouldInsertValuesAccordinglyIfStringsAreAddedAndReturnCountTwo()
 {
     RecentlyUsedList<string> nums = new RecentlyUsedList<string>(5);
     nums.AddItem("abc");
     nums.AddItem("xyz");
     int count = nums.NoOfElements();
     Assert.AreEqual(2, count, "Expected value is 2");
     Assert.AreEqual("xyz", nums[0], "Expected value is 5");
     Assert.AreEqual("abc", nums[1], "Expected value is 4");
 }
 public void ShouldAddClassObjectIntoListAccordinglyIfDuplicateObjectIsAdded()
 {
     RecentlyUsedList<Employee> nums = new RecentlyUsedList<Employee>(5);
     Employee e1 = new Employee { Age = 24, Name = "Arjita" };
     Employee e2 = new Employee { Age = 22, Name = "Garima" };
     //Employee e3 = new Employee { Age = 24, Name = "Arjita" };
     nums.AddItem(e1);
     nums.AddItem(e2);
     nums.AddItem(e1);
     int count = nums.NoOfElements();
     Assert.AreEqual(2, count, "Expected value is 2");
     Assert.AreEqual(24, nums[0].Age, "Expected value is 24");
     Assert.AreEqual("Arjita", nums[0].Name, "Expected value is Arjita");
     Assert.AreEqual(22, nums[1].Age, "Expected value is 22");
     Assert.AreEqual("Garima", nums[1].Name, "Expected value is Garima");
 }
 public void ShouldAddClassObjectIntoList()
 {
     RecentlyUsedList<Employee> nums = new RecentlyUsedList<Employee>(5);
     Employee e1 = new Employee { Age = 24, Name = "Arjita" };
     nums.AddItem(e1);
     int count = nums.NoOfElements();
     Assert.AreEqual(1, count, "Expected value is 1");
     Assert.AreEqual(24, nums[0].Age, "Expected value is 24");
     Assert.AreEqual("Arjita", nums[0].Name, "Expected value is Arjita");
 }
        public void ShouldGiveArgumentOutOfRangeExceptionWhenThirdIndexedElementIsSearchedOfThreeSizeList()
        {
            RecentlyUsedList<int> ListObject = new RecentlyUsedList<int>(5);

            ListObject.AddItem(12);
            ListObject.AddItem(8);
            ListObject.AddItem(32);

            var item = ListObject[3];
        }
        public void ShouldGiveArgumentOutOfRangeExceptionWhenMinusOneIndexedElementIsSearched()
        {
            RecentlyUsedList<int> ListObject = new RecentlyUsedList<int>(5);

            ListObject.AddItem(12);
            ListObject.AddItem(8);
            ListObject.AddItem(32);

            var item = ListObject[-1];
        }
 public void ShouldThrowExecptionIfAccessValueAtIndexWhichIsEmpty()
 {
     RecentlyUsedList<string> nums = new RecentlyUsedList<string>(5);
     nums.AddItem("abc");
     nums.AddItem("xyz");
     var a = nums[2];
 }
 public void ShouldAddClassObjectsIntoListAccordinglyIfOverFlowOccurs()
 {
     RecentlyUsedList<Employee> nums = new RecentlyUsedList<Employee>(5);
     Employee e1 = new Employee { Age = 24, Name = "Arjita" };
     Employee e2 = new Employee { Age = 22, Name = "Garima" };
     Employee e3 = new Employee { Age = 24, Name = "Mohit" };
     Employee e4 = new Employee { Age = 21, Name = "Arjita" };
     Employee e5 = new Employee { Age = 23, Name = "Garima" };
     Employee e6 = new Employee { Age = 21, Name = "Mohit" };
     nums.AddItem(e1);
     nums.AddItem(e2);
     nums.AddItem(e3);
     nums.AddItem(e4);
     nums.AddItem(e5);
     nums.AddItem(e6);
     int count = nums.NoOfElements();
     Assert.AreEqual(5, count, "Expected value is 5");
     Assert.AreEqual(21, nums[0].Age, "Expected value is 21");
     Assert.AreEqual("Mohit", nums[0].Name, "Expected value is Mohit");
     Assert.AreEqual(23, nums[1].Age, "Expected value is 23");
     Assert.AreEqual("Garima", nums[1].Name, "Expected value is Garima");
     Assert.AreEqual(21, nums[2].Age, "Expected value is 21");
     Assert.AreEqual("Arjita", nums[2].Name, "Expected value is Arjita");
     Assert.AreEqual(24, nums[3].Age, "Expected value is 24");
     Assert.AreEqual("Mohit", nums[3].Name, "Expected value is Mohit");
     Assert.AreEqual(22, nums[4].Age, "Expected value is 22");
     Assert.AreEqual("Garima", nums[4].Name, "Expected value is Garima");
 }
 public void ShouldReturnMohitWhenFirstIndexedEmployeeObjectNameIsCalled()
 {
     RecentlyUsedList<Employee> ListObject = new RecentlyUsedList<Employee>(5);
     Employee emp1 = new Employee();
     emp1.name = "Atrey";
     Employee emp2 = new Employee();
     emp2.name = "Mohit";
     Employee emp3 = new Employee();
     emp3.name = "Raj";
     ListObject.AddItem(emp1);
     ListObject.AddItem(emp2);
     ListObject.AddItem(emp3);
     
     Assert.AreEqual("Mohit", ListObject[1].name, "Mohit is not at the First Index.");
 }