public void TestRemoveNotifiesBoundListSubscriptions() { const int key = 0; const string item = "item"; bindableStringDictionary.Add(key, item); var listA = new BindableDictionary <int, string>(); listA.BindTo(bindableStringDictionary); NotifyCollectionChangedEventArgs triggeredArgsA1 = null; NotifyCollectionChangedEventArgs triggeredArgsA2 = null; listA.CollectionChanged += (_, args) => triggeredArgsA1 = args; listA.CollectionChanged += (_, args) => triggeredArgsA2 = args; var listB = new BindableDictionary <int, string>(); listB.BindTo(bindableStringDictionary); NotifyCollectionChangedEventArgs triggeredArgsB1 = null; NotifyCollectionChangedEventArgs triggeredArgsB2 = null; listB.CollectionChanged += (_, args) => triggeredArgsB1 = args; listB.CollectionChanged += (_, args) => triggeredArgsB2 = args; bindableStringDictionary.Remove(key); Assert.That(triggeredArgsA1, Is.Not.Null); Assert.That(triggeredArgsA2, Is.Not.Null); Assert.That(triggeredArgsB1, Is.Not.Null); Assert.That(triggeredArgsB2, Is.Not.Null); }
public void TestRemoveNotifiesBoundLists() { const int key = 0; const string item = "item"; bindableStringDictionary.Add(key, item); var listA = new BindableDictionary <int, string>(); listA.BindTo(bindableStringDictionary); var listB = new BindableDictionary <int, string>(); listB.BindTo(bindableStringDictionary); var listC = new BindableDictionary <int, string>(); listC.BindTo(bindableStringDictionary); bindableStringDictionary.Remove(key); Assert.Multiple(() => { Assert.False(listA.Contains(key)); Assert.False(listB.Contains(key)); Assert.False(listC.Contains(key)); }); }
public void TestRemoveNotifiesBoundDictionarySubscriptions() { const string item = "item"; bindableStringByteDictionary.Add(item, 0); var dictA = new BindableDictionary <string, byte>(); dictA.BindTo(bindableStringByteDictionary); NotifyDictionaryChangedEventArgs <string, byte> triggeredArgsA1 = null; NotifyDictionaryChangedEventArgs <string, byte> triggeredArgsA2 = null; dictA.CollectionChanged += (_, args) => triggeredArgsA1 = args; dictA.CollectionChanged += (_, args) => triggeredArgsA2 = args; var dictB = new BindableDictionary <string, byte>(); dictB.BindTo(bindableStringByteDictionary); NotifyDictionaryChangedEventArgs <string, byte> triggeredArgsB1 = null; NotifyDictionaryChangedEventArgs <string, byte> triggeredArgsB2 = null; dictB.CollectionChanged += (_, args) => triggeredArgsB1 = args; dictB.CollectionChanged += (_, args) => triggeredArgsB2 = args; bindableStringByteDictionary.Remove(item); Assert.That(triggeredArgsA1, Is.Not.Null); Assert.That(triggeredArgsA2, Is.Not.Null); Assert.That(triggeredArgsB1, Is.Not.Null); Assert.That(triggeredArgsB2, Is.Not.Null); }
public void TestBindCollectionChangedNotRunIfBoundToSequenceEqualDictionary() { var dict = new BindableDictionary <string, byte> { { "a", 1 }, { "b", 3 }, { "c", 5 }, { "d", 7 } }; var otherDict = new BindableDictionary <string, byte> { { "a", 1 }, { "b", 3 }, { "c", 5 }, { "d", 7 } }; NotifyDictionaryChangedEventArgs <string, byte> triggeredArgs = null; dict.BindCollectionChanged((_, args) => triggeredArgs = args); dict.BindTo(otherDict); Assert.That(triggeredArgs, Is.Null); }
public void TestDisabledNotifiesBoundDictionaries() { var dict = new BindableDictionary <string, byte>(); dict.BindTo(bindableStringByteDictionary); bindableStringByteDictionary.Disabled = true; Assert.IsTrue(dict.Disabled); }
public void TestAddWithStringNotifiesBoundDictionary(string key, byte value) { var dict = new BindableDictionary <string, byte>(); dict.BindTo(bindableStringByteDictionary); bindableStringByteDictionary.Add(key, value); Assert.That(dict, Contains.Key(key)); }
public void TestDisabledNotifiesBoundLists() { var list = new BindableDictionary <int, string>(); list.BindTo(bindableStringDictionary); bindableStringDictionary.Disabled = true; Assert.IsTrue(list.Disabled); }
protected override void OnApply() { base.OnApply(); lyricPieces.Clear(); lyricPieces.Add(new DefaultLyricPiece(HitObject)); SingersBindable.BindTo(HitObject.SingersBindable); LayoutIndexBindable.BindTo(HitObject.LayoutIndexBindable); TranslateTextBindable.BindTo(HitObject.TranslateTextBindable); }
public void TestAddWithStringNotifiesBoundList(string str) { var list = new BindableDictionary <int, string>(); list.BindTo(bindableStringDictionary); var item = new KeyValuePair <int, string>(0, str); bindableStringDictionary.Add(item); Assert.Contains(item, list); }
protected override void OnApply() { base.OnApply(); TextBindable.BindTo(HitObject.TextBindable); TimeTagsBindable.BindTo(HitObject.TimeTagsBindable); RubyTagsBindable.BindTo(HitObject.RubyTagsBindable); RomajiTagsBindable.BindTo(HitObject.RomajiTagsBindable); SingersBindable.BindTo(HitObject.SingersBindable); LayoutIndexBindable.BindTo(HitObject.LayoutIndexBindable); TranslateTextBindable.BindTo(HitObject.TranslateTextBindable); }
public void TestRemoveNotifiesBoundDictionary() { const string item = "item"; bindableStringByteDictionary.Add(item, 0); var dict = new BindableDictionary <string, byte>(); dict.BindTo(bindableStringByteDictionary); bindableStringByteDictionary.Remove(item); Assert.IsEmpty(dict); }
public void TestRemoveNotifiesBoundList() { const int key = 0; const string item = "item"; bindableStringDictionary.Add(key, item); var list = new BindableDictionary <int, string>(); list.BindTo(bindableStringDictionary); bindableStringDictionary.Remove(key); Assert.IsEmpty(list); }
public void TestClearNotifiesBoundBindable() { var bindableList = new BindableDictionary <int, string>(); bindableList.BindTo(bindableStringDictionary); for (int i = 0; i < 5; i++) { bindableStringDictionary.Add(i, "testA"); } for (int i = 0; i < 5; i++) { bindableList.Add(i + 5, "testA"); } bindableStringDictionary.Clear(); Assert.IsEmpty(bindableList); }
public void TestSetNotifiesBoundDictionaries() { bindableStringByteDictionary.Add("0", 0); var dict = new BindableDictionary <string, byte>(); dict.BindTo(bindableStringByteDictionary); NotifyDictionaryChangedEventArgs <string, byte> triggeredArgs = null; dict.CollectionChanged += (_, args) => triggeredArgs = args; bindableStringByteDictionary["0"] = 1; Assert.That(triggeredArgs.Action, Is.EqualTo(NotifyDictionaryChangedAction.Replace)); Assert.That(triggeredArgs.OldItems, Is.EquivalentTo(new KeyValuePair <string, byte>("0", 0).Yield())); Assert.That(triggeredArgs.NewItems, Is.EquivalentTo(new KeyValuePair <string, byte>("0", 1).Yield())); }
public void TestClearNotifiesBoundBindable() { var bindableDict = new BindableDictionary <string, byte>(); bindableDict.BindTo(bindableStringByteDictionary); for (byte i = 0; i < 5; i++) { bindableStringByteDictionary.Add($"testA{i}", i); } for (byte i = 0; i < 5; i++) { bindableDict.Add($"testB{i}", i); } bindableStringByteDictionary.Clear(); Assert.IsEmpty(bindableDict); }
public void TestRemoveNotifiesBoundDictionarySubscription() { const string item = "item"; bindableStringByteDictionary.Add(item, 0); var dict = new BindableDictionary <string, byte>(); dict.BindTo(bindableStringByteDictionary); NotifyDictionaryChangedEventArgs <string, byte> triggeredArgs = null; dict.CollectionChanged += (_, args) => triggeredArgs = args; bindableStringByteDictionary.Remove(item); Assert.That(triggeredArgs.Action, Is.EqualTo(NotifyDictionaryChangedAction.Remove)); Assert.That(triggeredArgs.OldItems, Is.EquivalentTo(new KeyValuePair <string, byte>(item, 0).Yield())); }
public void TestRemoveNotifiesBoundListSubscription() { const int key = 0; const string item = "item"; bindableStringDictionary.Add(key, item); var list = new BindableDictionary <int, string>(); list.BindTo(bindableStringDictionary); NotifyCollectionChangedEventArgs triggeredArgs = null; list.CollectionChanged += (_, args) => triggeredArgs = args; bindableStringDictionary.Remove(key); Assert.That(triggeredArgs.Action, Is.EqualTo(NotifyCollectionChangedAction.Remove)); Assert.That(triggeredArgs.OldItems, Has.One.Items.EqualTo(new KeyValuePair <int, string>(key, item))); Assert.That(triggeredArgs.OldStartingIndex, Is.EqualTo(0)); }
public void TestSetNotifiesBoundLists() { bindableStringDictionary.Add(0, "0"); var list = new BindableDictionary <int, string>(); list.BindTo(bindableStringDictionary); NotifyCollectionChangedEventArgs triggeredArgs = null; list.CollectionChanged += (_, args) => triggeredArgs = args; bindableStringDictionary[0] = "1"; Assert.That(triggeredArgs.Action, Is.EqualTo(NotifyCollectionChangedAction.Replace)); Assert.That(triggeredArgs.OldItems, Is.EquivalentTo(new KeyValuePair <int, string>(0, "0").Yield())); Assert.That(triggeredArgs.NewItems, Is.EquivalentTo(new KeyValuePair <int, string>(0, "1").Yield())); Assert.That(triggeredArgs.OldStartingIndex, Is.Zero); Assert.That(triggeredArgs.NewStartingIndex, Is.Zero); }
public void TestBindCollectionChangedEventsRanIfBoundToDifferentDictionary() { var firstDictContents = new[] { new KeyValuePair <string, byte>("a", 1), new KeyValuePair <string, byte>("b", 3), new KeyValuePair <string, byte>("c", 5), new KeyValuePair <string, byte>("d", 7), }; var otherDictContents = new[] { new KeyValuePair <string, byte>("a", 2), new KeyValuePair <string, byte>("b", 4), new KeyValuePair <string, byte>("c", 6), new KeyValuePair <string, byte>("d", 8), new KeyValuePair <string, byte>("e", 10), }; var dict = new BindableDictionary <string, byte>(firstDictContents); var otherDict = new BindableDictionary <string, byte>(otherDictContents); var triggeredArgs = new List <NotifyDictionaryChangedEventArgs <string, byte> >(); dict.BindCollectionChanged((_, args) => triggeredArgs.Add(args)); dict.BindTo(otherDict); Assert.That(triggeredArgs, Has.Count.EqualTo(2)); var removeEvent = triggeredArgs.SingleOrDefault(ev => ev.Action == NotifyDictionaryChangedAction.Remove); Assert.That(removeEvent, Is.Not.Null); Assert.That(removeEvent.OldItems, Is.EquivalentTo(firstDictContents)); var addEvent = triggeredArgs.SingleOrDefault(ev => ev.Action == NotifyDictionaryChangedAction.Add); Assert.That(addEvent, Is.Not.Null); Assert.That(addEvent.NewItems, Is.EquivalentTo(otherDict)); }
public void TestClearDoesNotNotifyBoundBindablesBeforeClear() { var bindableDictA = new BindableDictionary <string, byte>(); bindableDictA.BindTo(bindableStringByteDictionary); var bindableDictB = new BindableDictionary <string, byte>(); bindableDictB.BindTo(bindableStringByteDictionary); var bindableDictC = new BindableDictionary <string, byte>(); bindableDictC.BindTo(bindableStringByteDictionary); for (byte i = 0; i < 5; i++) { bindableStringByteDictionary.Add($"testA{i}", i); } for (byte i = 0; i < 5; i++) { bindableDictA.Add($"testB{i}", i); } for (byte i = 0; i < 5; i++) { bindableDictB.Add($"testC{i}", i); } for (byte i = 0; i < 5; i++) { bindableDictC.Add($"testD{i}", i); } Assert.Multiple(() => { Assert.IsNotEmpty(bindableDictA); Assert.IsNotEmpty(bindableDictB); Assert.IsNotEmpty(bindableDictC); }); bindableStringByteDictionary.Clear(); }
public void TestClearDoesNotNotifyBoundBindablesBeforeClear() { var bindableListA = new BindableDictionary <int, string>(); bindableListA.BindTo(bindableStringDictionary); var bindableListB = new BindableDictionary <int, string>(); bindableListB.BindTo(bindableStringDictionary); var bindableListC = new BindableDictionary <int, string>(); bindableListC.BindTo(bindableStringDictionary); for (int i = 0; i < 5; i++) { bindableStringDictionary.Add(i, "testA"); } for (int i = 0; i < 5; i++) { bindableListA.Add(i + 5, "testA"); } for (int i = 0; i < 5; i++) { bindableListB.Add(i + 10, "testA"); } for (int i = 0; i < 5; i++) { bindableListC.Add(i + 15, "testA"); } Assert.Multiple(() => { Assert.IsNotEmpty(bindableListA); Assert.IsNotEmpty(bindableListB); Assert.IsNotEmpty(bindableListC); }); bindableStringDictionary.Clear(); }
public void TestRemoveNotifiesBoundDictionaries() { const string item = "item"; bindableStringByteDictionary.Add(item, 0); var dictA = new BindableDictionary <string, byte>(); dictA.BindTo(bindableStringByteDictionary); var dictB = new BindableDictionary <string, byte>(); dictB.BindTo(bindableStringByteDictionary); var dictC = new BindableDictionary <string, byte>(); dictC.BindTo(bindableStringByteDictionary); bindableStringByteDictionary.Remove(item); Assert.Multiple(() => { Assert.False(dictA.ContainsKey(item)); Assert.False(dictB.ContainsKey(item)); Assert.False(dictC.ContainsKey(item)); }); }