public void AddRangeDuplicateInDictionary() { //**************************************** var MyRecords = new ObservableSortedList <int, int>(64); //**************************************** MyRecords[9] = 1; MyRecords[10] = 2; MyRecords[11] = 3; MyRecords[12] = 4; try { MyRecords.AddRange(new[] { new KeyValuePair <int, int>(1, 1), new KeyValuePair <int, int>(2, 2), new KeyValuePair <int, int>(3, 3), new KeyValuePair <int, int>(9, 4) }); Assert.Fail("Range succeeded"); } catch (ArgumentException) { } //**************************************** Assert.AreEqual(4, MyRecords.Count, "Items were added"); }
public void AddRangeCollide() { //**************************************** var MySeed = Environment.TickCount; var MyRandom = new Random(MySeed); var MyRecords = new ObservableSortedList <CollideStruct, int>(64); var MyDictionary = new Dictionary <CollideStruct, int>(64); //**************************************** for (var Index = 0; Index < 64; Index++) { CollideStruct Key; int Value; do { Key = new CollideStruct(MyRandom.Next()); } while (MyDictionary.ContainsKey(Key)); Value = MyRandom.Next(); MyDictionary.Add(Key, Value); } MyRecords.AddRange(MyDictionary); //**************************************** Assert.AreEqual(64, MyRecords.Count, "Count incorrect. Bad Seed was {0}", MySeed); CollectionAssert.AreEquivalent(MyDictionary, MyRecords, "Collections don't match. Bad Seed was {0}", MySeed); Thread.Sleep(1); }
public void AddRange() { //**************************************** var MySeed = Environment.TickCount; var MyRandom = new Random(MySeed); var MyRecords = new ObservableSortedList <int, int>(1024); var MyDictionary = new Dictionary <int, int>(1024); var MySortedList = new SortedList <int, int>(1024); //**************************************** while (MyDictionary.Count < 1024) { MyDictionary[MyRandom.Next()] = MyRandom.Next(); } foreach (var MyPair in MyDictionary) { MySortedList.Add(MyPair.Key, MyPair.Value); } MyRecords.AddRange(MySortedList); //**************************************** Assert.AreEqual(1024, MyRecords.Count, "Count incorrect. Bad Seed was {0}", MySeed); CollectionAssert.AreEqual(MySortedList, MyRecords, "Collections don't match. Bad Seed was {0}", MySeed); Thread.Sleep(1); }
public void EventAddRangeEmpty() { //**************************************** var MyRecords = new ObservableSortedList <int, int>(); NotifyCollectionChangedEventArgs MyEventArgs = null, MyKeyEventArgs = null, MyValueEventArgs = null; //**************************************** MyRecords.CollectionChanged += (sender, e) => MyEventArgs = e; MyRecords.Keys.CollectionChanged += (sender, e) => MyKeyEventArgs = e; MyRecords.Values.CollectionChanged += (sender, e) => MyValueEventArgs = e; MyRecords.AddRange(Enumerable.Empty <KeyValuePair <int, int> >()); //**************************************** Assert.IsNull(MyEventArgs, "Event Raised"); Assert.IsNull(MyKeyEventArgs, "Event Raised"); Assert.IsNull(MyValueEventArgs, "Event Raised"); }
public void AddRangeDuplicateInRange() { //**************************************** var MyRecords = new ObservableSortedList <int, int>(64); //**************************************** try { MyRecords.AddRange(new[] { new KeyValuePair <int, int>(1, 1), new KeyValuePair <int, int>(2, 2), new KeyValuePair <int, int>(3, 3), new KeyValuePair <int, int>(1, 4) }); Assert.Fail("Range succeeded"); } catch (ArgumentException) { } //**************************************** Assert.AreEqual(0, MyRecords.Count, "Items were added"); }