예제 #1
0
        public void ContainsPasses()
        {
            var helper = new HashSetHelper <int>();

            var value = 100;

            helper.Add(value);
            Assert.IsTrue(helper.Contains(value));

            helper.Remove(value);
            Assert.IsFalse(helper.Contains(value));

            helper.Add(value);
            Assert.IsTrue(helper.Contains(value));
        }
예제 #2
0
        public void AddPasses()
        {
            var helper = new HashSetHelper <int>();

            var value = 100;

            helper.Add(value);
            Assert.IsTrue(helper.Contains(value));
            Assert.AreEqual(1, helper.Count);

            var value2 = 101;

            helper.Add(value2);
            Assert.IsTrue(helper.Contains(value2));
            Assert.AreEqual(2, helper.Count);
        }
예제 #3
0
        public void AddWhenContainsPasses()
        {
            var helper = new HashSetHelper <int>();
            var value  = 100;

            helper.Add(value);

            Assert.DoesNotThrow(() => {
                helper.Add(value);
            });
            Assert.IsTrue(helper.Contains(value));
            Assert.AreEqual(1, helper.Count);
        }
예제 #4
0
        public void RemoveWhenNotContainsPasses()
        {
            var helper = new HashSetHelper <int>();

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

            foreach (var d in testData)
            {
                helper.Add(d);
            }
            helper.Remove(testData[0]);

            Assert.DoesNotThrow(() => {
                helper.Remove(testData[0]);
                Assert.IsFalse(helper.Contains(testData[0]));
            });

            Assert.DoesNotThrow(() => {
                helper.Remove(-123);
                Assert.IsFalse(helper.Contains(-123));
            });
        }
예제 #5
0
        public void OnAddedInAddWhenOccurExceptionPasses()
        {
            var helper = new HashSetHelper <int>();

            helper.OnAdded.Add((v) => {
                throw new System.Exception();
            });

            Assert.DoesNotThrow(() => {
                int value = 100;
                helper.Add(value);
                Assert.IsTrue(helper.Contains(value));
                Assert.AreEqual(1, helper.Count);
            });
        }
예제 #6
0
        public void ContainsWhenNotContainsPasses()
        {
            var helper = new HashSetHelper <int>();

            Assert.IsFalse(helper.Contains(100));
        }