Exemple #1
0
        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));
        }
Exemple #4
0
        public void ReplaceAllGroups_KeysOnlyAllowEmptyGroupNullKey_ArgumentNullException()
        {
            var collection = CollectionHelper.CreateFilledGroupsWithEmpty();

            Assert.Throws <ArgumentNullException>(
                () => collection.ReplaceAllGroups(CollectionHelper.KeysOneNull));
        }
Exemple #5
0
        public void InsertGroups_KeysOnlyAllowEmptyGroupDuplicateKey_ArgumentException()
        {
            var collection = CollectionHelper.CreateFilledGroupsWithEmpty();

            Assert.Throws <ArgumentException>(
                () => collection.InsertGroups(0, CollectionHelper.KeysOneFill));
        }
Exemple #6
0
        public void InsertGroups_KeysOnlyForbidEmptyGroupsOverSizedIndex_ArgumentOutOfRangeException()
        {
            var collection = CollectionHelper.CreateFilledGroupsWithEmpty();

            Assert.Throws <ArgumentOutOfRangeException>(
                () => collection.InsertGroups(collection.Keys.Count + 1, CollectionHelper.KeysNotContained));
        }
Exemple #7
0
        public void InsertGroups_WithItemsAllowEmptyGroupsDuplicateKeysWithEmptyItems_ArgumentException()
        {
            var collection = CollectionHelper.CreateFilledGroupsWithEmpty();

            Assert.Throws <ArgumentException>(
                () => collection.InsertGroups(0, CollectionHelper.PairDuplicateKeyWithEmptyItem));
        }
Exemple #8
0
        public void ReplaceAllGroups_KeysOnlyAllowEmptyGroupEmptyListOfKeys_CollectionIsEmpty()
        {
            var collection = CollectionHelper.CreateFilledGroupsWithEmpty();

            collection.ReplaceAllGroups(CollectionHelper.KeysEmpty);

            Assert.Equal(0, collection.Keys.Count);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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));
        }
Exemple #21
0
        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));
            }
        }
Exemple #22
0
        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));
        }