コード例 #1
0
        public void ClearWhenEmptyPasses()
        {
            var helper = new HashSetHelper <int>();

            Assert.DoesNotThrow(() => {
                helper.Clear();
            });
        }
コード例 #2
0
        public void OnClearedInClearWhenEmptyPasses()
        {
            var helper  = new HashSetHelper <int>();
            var counter = 0;

            helper.OnCleared.Add(() => counter++);

            helper.Clear();

            Assert.AreEqual(0, counter);
        }
コード例 #3
0
        public void OnChangedCountInClearNotRemovePasses()
        {
            var helper = new HashSetHelper <int>();

            var isCall = false;

            helper.OnChangedCount.Add((_helper, _count) => {
                isCall = true;
            });

            helper.Clear();
            Assert.IsFalse(isCall);
        }
コード例 #4
0
        public void ClearPasses()
        {
            var helper = new HashSetHelper <int>();

            var testData = new int[] {
                0, 1, 2, 3, 4
            };

            foreach (var d in testData)
            {
                helper.Add(d);
            }

            helper.Clear();
            Assert.AreEqual(0, helper.Count);
        }
コード例 #5
0
        public void OnChangedCountInClearWhenOccurExceptionPasses()
        {
            var helper = new HashSetHelper <int>();

            helper.Add(1, 2, 3);
            helper.OnChangedCount.Add((_helper, _count) => {
                throw new System.NotImplementedException();
            });

            helper.Clear();

            AssertionUtils.AssertEnumerableByUnordered(
                new int[] { },
                helper.Items,
                ""
                );
        }
コード例 #6
0
        public void OnChangedCountInClearPasses()
        {
            var helper = new HashSetHelper <int>();

            helper.Add(1, 2, 3);
            var callCounter  = 0;
            var recievedData = (self : (IReadOnlyHashSetHelper <int>)null, count : (int)0);

            helper.OnChangedCount.Add((_helper, _count) => {
                callCounter++;
                recievedData.self  = _helper;
                recievedData.count = _count;
            });

            helper.Clear();
            Assert.AreEqual(1, callCounter);
            Assert.AreEqual(helper, recievedData.self);
            Assert.AreEqual(helper.Count, recievedData.count);
        }
コード例 #7
0
        public void OnClearedInClearPasses()
        {
            var helper  = new HashSetHelper <int>();
            var counter = 0;

            helper.OnCleared.Add(() => counter++);

            var testData = new int[] {
                0, 1, 2, 3, 4
            };

            foreach (var d in testData)
            {
                helper.Add(d);
            }

            helper.Clear();
            Assert.AreEqual(1, counter);
        }
コード例 #8
0
        public void ClearInClearWhenOccurExceptionPasses()
        {
            var helper = new HashSetHelper <int>();

            helper.OnCleared.Add(() => throw new System.Exception());

            var testData = new int[] {
                0, 1, 2, 3, 4
            };

            foreach (var d in testData)
            {
                helper.Add(d);
            }

            Assert.DoesNotThrow(() => {
                helper.Clear();
                Assert.AreEqual(0, helper.Count);
            });
        }
コード例 #9
0
        public void OnChangedCountInClearWhenOccurOnRemovedExceptionPasses()
        {
            var helper = new HashSetHelper <int>();
            var value  = 1;

            helper.Add(value, 2, 3, 4);
            helper.OnRemoved.Add((_v) => {
                throw new System.NotImplementedException();
            });
            var callCounter = 0;

            helper.OnChangedCount.Add((_, __) => callCounter++);

            helper.Clear();

            Assert.AreEqual(1, callCounter);
            AssertionUtils.AssertEnumerableByUnordered(
                new int[] { },
                helper.Items,
                ""
                );
        }
コード例 #10
0
        public void OnRemovedInClearPasses()
        {
            var helper        = new HashSetHelper <int>();
            var counter       = 0;
            var recievedValue = new List <int>();

            helper.OnRemoved.Add((v) => { counter++; recievedValue.Add(v); });

            var testData = new int[] {
                100, 200
            };

            foreach (var d in testData)
            {
                helper.Add(d);
            }

            Assert.AreEqual(0, counter);
            helper.Clear();
            Assert.AreEqual(testData.Length, counter);
            AssertionUtils.AssertEnumerableByUnordered(testData, recievedValue, "");
        }