public void InsertGroups_KeysOnlyAllowEmptyGroupNullListOfKeys_ArgumentNullException() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); Assert.Throws <ArgumentNullException>( () => collection.InsertGroups(0, CollectionHelper.KeysNull)); }
public void ClearGroup_AllowEmptyGroupMissingKey_KeyNotFoundException() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); Assert.Throws <KeyNotFoundException>( () => collection.ClearGroup(CollectionHelper.GroupKeyThird)); }
public void ClearGroup_AllowEmptyGroupNullKey_ArgumentNullException() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); Assert.Throws <ArgumentNullException>( () => collection.ClearGroup(null)); }
public void ReplaceAllGroups_KeysOnlyAllowEmptyGroupNullKey_ArgumentNullException() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); Assert.Throws <ArgumentNullException>( () => collection.ReplaceAllGroups(CollectionHelper.KeysOneNull)); }
public void InsertGroups_KeysOnlyAllowEmptyGroupDuplicateKey_ArgumentException() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); Assert.Throws <ArgumentException>( () => collection.InsertGroups(0, CollectionHelper.KeysOneFill)); }
public void InsertGroups_KeysOnlyForbidEmptyGroupsOverSizedIndex_ArgumentOutOfRangeException() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); Assert.Throws <ArgumentOutOfRangeException>( () => collection.InsertGroups(collection.Keys.Count + 1, CollectionHelper.KeysNotContained)); }
public void InsertGroups_WithItemsAllowEmptyGroupsDuplicateKeysWithEmptyItems_ArgumentException() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); Assert.Throws <ArgumentException>( () => collection.InsertGroups(0, CollectionHelper.PairDuplicateKeyWithEmptyItem)); }
public void ReplaceAllGroups_KeysOnlyAllowEmptyGroupEmptyListOfKeys_CollectionIsEmpty() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); collection.ReplaceAllGroups(CollectionHelper.KeysEmpty); Assert.Equal(0, collection.Keys.Count); }
public void InsertGroups_WithItemsAllowEmptyGroupsUniqueKeysWithEmptyItems_CollectionSizeIncreased() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var pair = CollectionHelper.PairNotContainedKeyWithEmptyItem; var expectedCount = collection.Count + pair.Count; collection.InsertGroups(0, pair); Assert.Equal(expectedCount, collection.Count); }
public void InsertGroups_KeysOnlyAllowEmptyGroupEmptyListOfKeys_CollectionSizeNotChanged() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var keys = CollectionHelper.KeysEmpty; var expected = collection.Count + keys.Count; collection.InsertGroups(0, keys); Assert.Equal(expected, collection.Keys.Count); }
public void InsertGroups_KeysOnlyAllowEmptyGroupUniqueKey_CollectionSizeIncreased() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var keys = CollectionHelper.KeysNotContained; var expected = collection.Count + keys.Count; collection.InsertGroups(0, keys); Assert.Equal(expected, collection.Keys.Count); }
public void ClearGroup_AllowEmptyGroupExistKey_ItemsRemoved() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var key = CollectionHelper.GroupKeyFirst; var startCount = collection.FirstOrDefault(x => x.Key == key)?.Count() ?? 0; collection.ClearGroup(key); var currentCount = collection.FirstOrDefault(x => x.Key == key)?.Count() ?? -1; Assert.True((startCount > 0) && currentCount == 0); }
public void ItemsChanged_ClearGroupOnlyAllowEmptyExistKey_NotifyOneTime() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var catcher = CollectionHelper.CreateItemsEventCatcher(collection); catcher.Subscribe(); collection.ClearGroup(CollectionHelper.GroupKeyFirst); catcher.Unsubscribe(); Assert.Equal(1, catcher.EventCount); }
public void CollectionChanged_ClearGroupAllowEmptyExistKey_NotNotify() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var catcher = CollectionHelper.CreateCollectionEventCatcher(collection); catcher.Subscribe(); collection.ClearGroup(CollectionHelper.GroupKeyFirst); catcher.Unsubscribe(); Assert.Equal(0, catcher.EventCount); }
public void ItemsChanged_InsertGroupsKeysOnlyAllowEmptyGroupUniqueKey_NotifyOneTime() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var catcher = CollectionHelper.CreateItemsEventCatcher(collection); catcher.Subscribe(); collection.InsertGroups(0, CollectionHelper.KeysNotContained); catcher.Unsubscribe(); Assert.Equal(1, catcher.EventCount); }
public void ItemsChanged_ClearGroupOnlyAllowEmptyExistKey_NotifyResetEvent() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var catcher = CollectionHelper.CreateItemsEventCatcher(collection); catcher.Subscribe(); collection.ClearGroup(CollectionHelper.GroupKeyFirst); catcher.Unsubscribe(); Assert.True(catcher.IsExpectedEvent(NotifyCollectionChangedAction.Reset)); }
public void ItemsChanged_RemoveItemsAllowEmptyGroupRemoveAllGroupItems_NotifyOneTime() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var items = CollectionHelper.RemoveItemsOnlyExistItemsForFirstGroup(); var catcher = CollectionHelper.CreateItemsEventCatcher(collection); catcher.Subscribe(); collection.RemoveItems(items, x => x.SelectKey(), x => x.SelectValue()); catcher.Unsubscribe(); Assert.Equal(1, catcher.EventCount); }
public void ItemsChanged_RemoveItemsAllowEmptyGroupRemoveAllGroupItems_NotifyRemoveEvent() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var items = CollectionHelper.RemoveItemsOnlyExistItemsForFirstGroup(); var catcher = CollectionHelper.CreateItemsEventCatcher(collection); catcher.Subscribe(); collection.RemoveItems(items, x => x.SelectKey(), x => x.SelectValue()); catcher.Unsubscribe(); Assert.True(catcher.IsExpectedEvent(NotifyCollectionChangedAction.Remove, items.Select(x => x.Value).ToList())); }
public void ItemsChanged_ReplaceAllGroupsKeysOnlyAllowEmptyGroupWithKeys_NotifyOneTime() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var keys = CollectionHelper.KeysOneContainedOneNotContained; var catcher = CollectionHelper.CreateItemsEventCatcher(collection); catcher.Subscribe(); collection.ReplaceAllGroups(keys); catcher.Unsubscribe(); Assert.Equal(1, catcher.EventCount); }
public void CollectionChanged_ReplaceAllGroupsKeysOnlyAllowEmptyGroupWithKeys_NotifyReplaceEvent() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var keys = CollectionHelper.KeysOneContainedOneNotContained; var catcher = CollectionHelper.CreateCollectionEventCatcher(collection); catcher.Subscribe(); collection.ReplaceAllGroups(keys); catcher.Unsubscribe(); Assert.True(catcher.IsExpectedEvent(NotifyCollectionChangedAction.Replace, keys)); }
public void ReplaceAllGroups_WithItemsAllowEmptyGroupsCorrectKeysWithEmptyItems_CollectionContainsOnlyNewKeys() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var pairs = CollectionHelper.PairWithKeyWithEmptyItem; collection.ReplaceAllGroups(pairs); Assert.Equal(pairs.Count, collection.Count); foreach (var item in collection) { Assert.True(item.SequenceEqual(pairs.FirstOrDefault(x => x.Key == item.Key).Value)); } }
public void ReplaceAllGroups_KeysOnlyAllowEmptyGroupCorrectKeys_CollectionContainsOnlyNewKeys() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var keys = CollectionHelper.KeysOneContainedOneNotContained; collection.ReplaceAllGroups(keys); foreach (var key in keys) { Assert.True(collection.Keys.Contains(key)); } Assert.Equal(keys.Count, collection.Keys.Count); }
public void CollectionChanged_InsertGroupsKeysOnlyAllowEmptyGroupUniqueKey_NotifyAddEvent() { var collection = CollectionHelper.CreateFilledGroupsWithEmpty(); var keys = CollectionHelper.KeysNotContained; var catcher = CollectionHelper.CreateCollectionEventCatcher(collection); catcher.Subscribe(); collection.InsertGroups(0, keys); catcher.Unsubscribe(); Assert.True(catcher.IsExpectedEvent(NotifyCollectionChangedAction.Add, keys)); }