private void AssertMockEventNotifiers(int timesPropertyCalled, int timesCollectionCalled, int timesDictionaryCalled) { //Sets up event testers MockEvent.Verify(m => m.Call("PropertyChanged"), Times.Exactly(timesPropertyCalled)); MockEvent.Verify(m => m.Call("CollectionChanged"), Times.Exactly(timesCollectionCalled)); MockEvent.Verify(m => m.Call("DictionaryChanged"), Times.Exactly(timesDictionaryCalled)); }
public void TestMethod_RemoveWithIndex() { var key1 = "a"; //0 var key2 = "c"; //2 var key3 = "b"; //1 var value1 = Fixture.Create <string>(); var value2 = Fixture.Create <string>(); var value3 = Fixture.Create <string>(); ObvDictionary.Add(key1, value1); ObvDictionary.Add(key2, value2); ObvDictionary.Add(key3, value3); Log(ObvDictionary.SortedList.IndexOfKey(key1)); Log(ObvDictionary.SortedList.IndexOfKey(key2)); Log(ObvDictionary.SortedList.IndexOfKey(key3)); ObvDictionary.CollectionChanged += (sender, args) => { Assert.That(args.OldItems[0], Is.EqualTo(value2)); Assert.That(args.OldStartingIndex, Is.EqualTo(2)); Assert.That(args.NewItems, Is.Null); Assert.That(args.NewStartingIndex, Is.EqualTo(-1)); AssertEvent.Call("collection"); }; ObvDictionary.Remove(key2); MockEvent.Verify(m => m.Call("collection"), Times.Exactly(1)); }
public void TestMethod_PropertyNotify() { SourceObvListB = new ObservableList <SourceItemB>(); DestObvListB = new ObservableList <DestItemB>(); ObvListSyncB = new ObservableListSynchronizerFunc <SourceItemB, DestItemB>( (sourceItem) => new DestItemB(sourceItem), (destItem) => destItem.SourceItem, SourceObvListB, DestObvListB, true, true ); var item1 = new SourceItemB { MyNum = 10, MyStringLower = "x" }; var item2 = new DestItemB { MyNum = "1000", MyStringUpper = "A" }; SourceObvListB.Add(item1); DestObvListB.Add(item2); SourceObvListB[0].PropertyChanged += (sender, args) => AssertEvent.Call("source[0] event"); DestObvListB[0].PropertyChanged += (sender, args) => AssertEvent.Call("dest[0] event"); SourceObvListB[1].PropertyChanged += (sender, args) => AssertEvent.Call("source[1] event"); DestObvListB[1].PropertyChanged += (sender, args) => AssertEvent.Call("dest[1] event"); var string1 = "TEST STRING"; var string2 = "TEST STRING AGAIN"; SourceObvListB[0].MyNum = -1; DestObvListB[1].MyStringUpper = string1; DestObvListB[1].MyStringUpper = string2; Assert.AreEqual(string2, DestObvListB[1].MyStringUpper); Assert.AreEqual(string2.ToLower(), SourceObvListB[1].MyStringLower); MockEvent.Verify(m => m.Call("source[0] event"), Times.Exactly(1)); MockEvent.Verify(m => m.Call("dest[0] event"), Times.Exactly(1)); MockEvent.Verify(m => m.Call("source[1] event"), Times.Exactly(2)); MockEvent.Verify(m => m.Call("dest[1] event"), Times.Exactly(2)); }
public void TestMethod_ReplaceValue() { ObvDictionary.Add(DefaultKey, DefaultValue); ObvDictionary.DictionaryChanged += (sender, args) => { Assert.That(args.Action == NotifyDictionaryChangedAction.Replace); Assert.That(args.OldKeys[0], Is.EqualTo(DefaultKey)); Assert.That(args.OldItems[0], Is.EqualTo(DefaultValue)); Assert.That(args.NewKeys[0], Is.EqualTo(DefaultKey)); Assert.That(args.NewItems[0], Is.EqualTo(UpdateValue)); AssertEvent.Call("DictionaryChanged"); }; ObvDictionary[DefaultKey] = UpdateValue; MockEvent.Verify(m => m.Call("DictionaryChanged"), Times.Exactly(1)); }
public void TestMethod_SetConstructorAndAdd() { ListAdapter = new ObservableListAdapterConcrete(TestBaseList); TestBaseList.PropertyChanged += (sender, args) => AssertEvent.Call("PropertyChanged"); TestBaseList.CollectionChanged += (sender, args) => AssertEvent.Call("CollectionChanged"); TestBaseList.Add(Item1); TestBaseList.Add(Item2); TestBaseList.Add(Item3); Assert.That(ListAdapter.Count, Is.EqualTo(3)); Assert.That(Item1, Is.EqualTo(ListAdapter.First().BaseString)); Assert.That(Item2, Is.EqualTo(ListAdapter[1].BaseString)); Assert.That(Item3, Is.EqualTo(ListAdapter[2].BaseString)); Assert.That(Item1 + ListAdapter.First().AddedString, Is.EqualTo(ListAdapter.First().StringView)); MockEvent.Verify(m => m.Call("PropertyChanged"), Times.Exactly(6)); MockEvent.Verify(m => m.Call("CollectionChanged"), Times.Exactly(3)); }
private void AssertMockNotifiers(int timesPropertyCalled, int timesCollectionCalled) { MockEvent.Verify(m => m.Call("PropertyChanged"), Times.Exactly(timesPropertyCalled)); MockEvent.Verify(m => m.Call("CollectionChanged"), Times.Exactly(timesCollectionCalled)); }