public void XLRangesCountChangesCorrectly() { using (var wb = new XLWorkbook()) { var ws = wb.Worksheets.Add("Sheet1") as XLWorksheet; var range1 = ws.Range("A1:B2"); var range2 = ws.Range("A2:B3"); var range3 = ws.Range("A1:B2"); // same as range1 var ranges = new XLRanges(); ranges.Add(range1); Assert.AreEqual(1, ranges.Count); ranges.Add(range2); Assert.AreEqual(2, ranges.Count); ranges.Add(range3); Assert.AreEqual(2, ranges.Count); Assert.AreEqual(ranges.Count, ranges.Count()); ranges.Remove(range3); Assert.AreEqual(1, ranges.Count); ranges.Remove(range2); Assert.AreEqual(0, ranges.Count); ranges.Remove(range1); Assert.AreEqual(0, ranges.Count); } }
public void XLRangesCountChangesCorrectly() { using (var wb = new XLWorkbook()) { var ws = wb.Worksheets.Add("Sheet1") as XLWorksheet; var range1 = ws.Range("A1:B2"); var range2 = ws.Range("A2:B3"); var range3 = ws.Range("A1:B2"); // same as range1 var ranges = new XLRanges(); ranges.Add(range1); Assert.AreEqual(1, ranges.Count); ranges.Add(range2); Assert.AreEqual(2, ranges.Count); ranges.Add(range3); Assert.AreEqual(2, ranges.Count); Assert.AreEqual(ranges.Count, ranges.Count()); // Add many entries to activate QuadTree for (int i = 1; i <= TEST_COUNT; i++) { ranges.Add(ws.Range(i * 2, 2, i * 2, 4)); } Assert.AreEqual(2 + TEST_COUNT, ranges.Count); for (int i = 1; i <= TEST_COUNT; i++) { ranges.Remove(ws.Range(i * 2, 2, i * 2, 4)); } Assert.AreEqual(2, ranges.Count); ranges.Remove(range3); Assert.AreEqual(1, ranges.Count); ranges.Remove(range2); Assert.AreEqual(0, ranges.Count); ranges.Remove(range1); Assert.AreEqual(0, ranges.Count); } }