public void TestWithOneEntry() { var testName = "TestUser"; var testNumbers = new SortedSet<string> { "+359899777235", "+359888777777" }; ListEntry[] expected = new ListEntry[] { new ListEntry { Name = testName, Numbers = testNumbers } }; var testPhoneDatabase = new PhonebookRepository(); testPhoneDatabase.AddPhone("TestUser", new string[] { "+359899777235" }); testPhoneDatabase.AddPhone("testuser", new string[] { "+359888777777" }); var actual = testPhoneDatabase.ListEntries(0, 1); Assert.AreEqual(expected.Count(), actual.Count()); IEnumerator e1 = expected.GetEnumerator(); IEnumerator e2 = actual.GetEnumerator(); while (e1.MoveNext() && e2.MoveNext()) { Assert.AreEqual(e1.Current.ToString(), e2.Current.ToString()); } }
public void TestWithSeveralEntries() { var testNameOne = "TestUserOne"; var testNameTwo = "TestUserTwo"; var testNumbersOne = new SortedSet<string> { "+359899777235" }; var testNumbersTwo = new SortedSet<string> { "+359888777777" }; ListEntry listEntryOne = new ListEntry { Name = testNameOne, Numbers = testNumbersOne }; ListEntry listEntryTwo = new ListEntry { Name = testNameTwo, Numbers = testNumbersTwo }; ListEntry[] expected = new ListEntry[] { listEntryOne, listEntryTwo }; var testPhoneDatabase = new PhonebookRepository(); testPhoneDatabase.AddPhone("TestUserOne", new string[] { "+359899777235" }); testPhoneDatabase.AddPhone("TestUserTwo", new string[] { "+359888777777" }); var actual = testPhoneDatabase.ListEntries(0, 2); Assert.AreEqual(expected.Count(), actual.Count()); IEnumerator e1 = expected.GetEnumerator(); IEnumerator e2 = actual.GetEnumerator(); while (e1.MoveNext() && e2.MoveNext()) { Assert.AreEqual(e1.Current.ToString(), e2.Current.ToString()); } }