public void TestAddAllKeepsSorted() { this.names = new SimpleSortedList <string>(); string[] input = new string[] { "qwerty", "yup", "Uhaaa", "Baba", "asdf" }; names.AddAll(input); FieldInfo namesType = names.GetType().GetField("innerCollection", BindingFlags.NonPublic | BindingFlags.Instance); string[] resultCollection = ((string[])namesType.GetValue(names)).Take(input.Length).ToArray(); string[] expectedCollection = new string[] { "asdf", "Baba", "qwerty", "Uhaaa", "yup" }; Assert.That(resultCollection, Is.EquivalentTo(expectedCollection)); }
public void TestAddUnsortedData_IsHeldSorted() { this.names = new SimpleSortedList <string>(); names.Add("Rosen"); names.Add("Georgi"); names.Add("Bobi"); FieldInfo namesType = names.GetType().GetField("innerCollection", BindingFlags.NonPublic | BindingFlags.Instance); string[] resultCollection = ((string[])namesType.GetValue(names)).Take(4).ToArray(); string[] expectedCollection = new string[] { "Bobi", "Georgi", "Rosen", null }; Assert.That(resultCollection, Is.EquivalentTo(expectedCollection)); }
public void TestRemoveValidElement_RemovesSelectedOne(string itemToRemove) { this.names = new SimpleSortedList <string>(); string[] input = new string[] { "qwerty", "yup", "Uhaaa", "Baba", "asdf" }; names.AddAll(input); bool result = names.Remove(itemToRemove); FieldInfo namesType = names.GetType().GetField("innerCollection", BindingFlags.NonPublic | BindingFlags.Instance); Assert.That(namesType.GetValue(names), Has.No.Member(itemToRemove)); Assert.That(this.names.Size, Is.EqualTo(input.Length - 1)); Assert.That(result == true); }