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 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 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"); }