public void ClearWhenEmptyPasses() { var helper = new HashSetHelper <int>(); Assert.DoesNotThrow(() => { helper.Clear(); }); }
public void OnClearedInClearWhenEmptyPasses() { var helper = new HashSetHelper <int>(); var counter = 0; helper.OnCleared.Add(() => counter++); helper.Clear(); Assert.AreEqual(0, counter); }
public void OnChangedCountInClearNotRemovePasses() { var helper = new HashSetHelper <int>(); var isCall = false; helper.OnChangedCount.Add((_helper, _count) => { isCall = true; }); helper.Clear(); Assert.IsFalse(isCall); }
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); }
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, "" ); }
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); }
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); }
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); }); }
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, "" ); }
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, ""); }