Ejemplo n.º 1
0
 public void AppendRow_MaxExtents_ThrowsException()
 {
     SafeExecuteTest(
         MaxExtentsSheetPath,
         (sheetData) =>
         {
             var target = new ArrayBasedSheetDataIndexer(sheetData);
             target.AppendRow(new Row());
         });
 }
Ejemplo n.º 2
0
        public void Constructor_EmptySheetData_ValidEmptyState()
        {
            SafeExecuteTest(
                EmptySheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);

                    Assert.IsNotNull(target);
                    Assert.IsTrue(target.IsEmpty);
                    Assert.AreEqual(0, target.Count);
                });
        }
Ejemplo n.º 3
0
        public void AppendRow_EmptySpreadsheet_IncreasesCountByOne()
        {
            SafeExecuteTest(
                EmptySheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);
                    target.AppendRow(new Row());

                    Assert.IsFalse(target.IsEmpty);
                    Assert.AreEqual(1, target.Count);
                    Assert.AreEqual(1, target.MaxRowIndex); // Row indices are one based.
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 4
0
        public void Constructor_MaxExtents_ValidState()
        {
            SafeExecuteTest(
                MaxExtentsSheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);

                    Assert.IsNotNull(target);
                    Assert.IsFalse(target.IsEmpty);
                    Assert.AreEqual(2, target.Count);
                    Assert.AreEqual(ArrayBasedSheetDataIndexer.Capacity, target.MaxRowIndex);
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 5
0
 public void RemoveRow_OverCapacityIndex_ThrowsException()
 {
     SafeExecuteTest(
         EmptySheetPath,
         (sheetData) =>
         {
             var target = new ArrayBasedSheetDataIndexer(sheetData);
             target.RemoveRow(ArrayBasedSheetDataIndexer.Capacity + 2); // Row indices are one based, hence the +2 is needed
         });
 }
Ejemplo n.º 6
0
 public void RemoveRow_NonExistentRow_ReturnsFalse()
 {
     SafeExecuteTest(
         ExactlyFiveRowsSheetPath,
         (sheetData) =>
         {
             var target = new ArrayBasedSheetDataIndexer(sheetData);
             Assert.IsFalse(target.RemoveRow(6));
             ValidateRowSequence(target);
         });
 }
Ejemplo n.º 7
0
 public void RemoveRow_NegativeIndex_ThrowsException()
 {
     SafeExecuteTest(
         EmptySheetPath,
         (sheetData) =>
         {
             var target = new ArrayBasedSheetDataIndexer(sheetData);
             target.RemoveRow(-1);
         });
 }
Ejemplo n.º 8
0
 public void InsertRow_IndexOverCapacity_ThrowsException()
 {
     SafeExecuteTest(
         ExactlyFiveRowsSheetPath,
         (sheetData) =>
         {
             var target = new ArrayBasedSheetDataIndexer(sheetData);
             target.InsertRow(new Row(), ArrayBasedSheetDataIndexer.Capacity + 1);
         });
 }
Ejemplo n.º 9
0
 public void Constructor_NullArgument_ExceptionThrown()
 {
     var target = new ArrayBasedSheetDataIndexer(null);
 }
Ejemplo n.º 10
0
        public void InsertRow_SequentialMiddleRowShift_IncreasesCountAndMaxRowByOne()
        {
            SafeExecuteTest(
                ExactlyFiveRowsSheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);
                    var halfway = (target.Rows.ToList().Count / 2) + 1;

                    var oldCount = target.Count;
                    var oldMaxRow = target.MaxRowIndex;

                    target.InsertRow(new Row(), halfway, true);
                    Assert.IsFalse(target.IsEmpty);
                    Assert.AreEqual(oldCount + 1, target.Count);
                    Assert.AreEqual(oldMaxRow + 1, target.MaxRowIndex);
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 11
0
        public void InsertRow_SequentialMiddleRowNoShift_DoesNotIncreaseCountOrMaxRow()
        {
            SafeExecuteTest(
                ExactlyFiveRowsSheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);
                    var halfway = target.Rows.ToList().Count / 2;

                    var oldCount = target.Count;
                    var oldMaxRow = target.MaxRowIndex;

                    target.InsertRow(new Row(), halfway);
                    Assert.IsFalse(target.IsEmpty);
                    Assert.AreEqual(oldCount, target.Count);
                    Assert.AreEqual(oldMaxRow, target.MaxRowIndex);
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 12
0
        public void InsertRow_SequentialMaxRowNoShift_IncreasesCountByOne()
        {
            SafeExecuteTest(
                ExactlyFiveRowsSheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);

                    var oldCount = target.Count;
                    var oldMaxRow = target.MaxRowIndex;

                    target.InsertRow(new Row(), target.MaxRowIndex);
                    Assert.IsFalse(target.IsEmpty);
                    Assert.AreEqual(oldCount, target.Count);
                    Assert.AreEqual(oldMaxRow, target.MaxRowIndex);
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 13
0
 public void InsertRow_NullRowArgument_ThrowsException()
 {
     SafeExecuteTest(
         EmptySheetPath,
         (sheetData) =>
         {
             var target = new ArrayBasedSheetDataIndexer(sheetData);
             target.InsertRow(null, 1);
         });
 }
Ejemplo n.º 14
0
        public void InsertRow_NonExistingIndexShift_IncreasesCountAndMaxRow()
        {
            SafeExecuteTest(
                FiveEvenRowsSheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);

                    var oldCount = target.Count;
                    var oldMaxRow = target.MaxRowIndex;

                    target.InsertRow(new Row(), 1, true); // insert at an odd index, test file has only even rows
                    Assert.IsFalse(target.IsEmpty);
                    Assert.AreEqual(oldCount + 1, target.Count);
                    Assert.AreEqual(oldMaxRow + 1, target.MaxRowIndex);
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 15
0
 public void InsertRow_NegativeIndex_ThrowsException()
 {
     SafeExecuteTest(
         ExactlyFiveRowsSheetPath,
         (sheetData) =>
         {
             var target = new ArrayBasedSheetDataIndexer(sheetData);
             target.InsertRow(new Row(), -1);
         });
 }
Ejemplo n.º 16
0
        public void RemoveRow_SequentialMiddleRowShiftUp_DecreasesCountAndMaxRowByOne()
        {
            SafeExecuteTest(
                ExactlyFiveRowsSheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);

                    var oldCount = target.Count;
                    var oldMaxRowIndex = target.MaxRowIndex;

                    Assert.IsTrue(target.RemoveRow(target.Rows.First().RowIndex, true));
                    Assert.AreEqual(oldCount - 1, target.Count);
                    Assert.AreEqual(oldMaxRowIndex - 1, target.MaxRowIndex);
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 17
0
        public void RowsProperty_ExactlyFiveRows_NoNulls()
        {
            SafeExecuteTest(
                ExactlyFiveRowsSheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);
                    var rows = target.Rows.ToList();

                    Assert.AreEqual(5, rows.Count);
                    Assert.AreEqual(target.Count, rows.Count);
                    Assert.IsTrue(rows.TrueForAll(x => x != null));
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 18
0
        public void MaxRowIndexProperty_EmptySheetData_ThrowsException()
        {
            SafeExecuteTest(
                EmptySheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);

                    Assert.IsNotNull(target);
                    Assert.IsTrue(target.IsEmpty);
                    Assert.AreEqual(0, target.Count);
                    var index = target.MaxRowIndex; // should throw here
                });
        }
Ejemplo n.º 19
0
 public void RemoveRow_EmptySpreadsheet_DoesNothing()
 {
     SafeExecuteTest(
         EmptySheetPath,
         (sheetData) =>
         {
             var target = new ArrayBasedSheetDataIndexer(sheetData);
             target.RemoveRow(0);
         });
 }
Ejemplo n.º 20
0
        public void RemoveRow_MaxRowShift_DecreasesCountByOne()
        {
            SafeExecuteTest(
                ExactlyFiveRowsSheetPath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);

                    var oldCount = target.Count;
                    var oldMaxRowIndex = target.MaxRowIndex;

                    Assert.IsTrue(target.RemoveRow(target.MaxRowIndex, true));
                    Assert.AreEqual(oldCount - 1, target.Count);
                    Assert.AreNotEqual(oldMaxRowIndex, target.MaxRowIndex); // Might not necessarily be minus one.
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 21
0
        public void Constructor_ValidSheetData_ValidState()
        {
            SafeExecuteTest(
                RandomDataSheetSpath,
                (sheetData) =>
                {
                    var target = new ArrayBasedSheetDataIndexer(sheetData);

                    Assert.IsNotNull(target);
                    Assert.IsFalse(target.IsEmpty);

                    // These magic numbers can only be determined from the test spreadsheet.
                    Assert.AreEqual(10, target.Count);
                    Assert.AreEqual(14, target.MaxRowIndex);
                    ValidateRowSequence(target);
                });
        }
Ejemplo n.º 22
0
 public void ImplicitCast_ValidIndexer_SameReference()
 {
     SafeExecuteTest(
         EmptySheetPath,
         (sheetData) =>
         {
             var indexer = new ArrayBasedSheetDataIndexer(sheetData);
             var target = (SheetData)indexer;
             Assert.AreSame(sheetData, target);
         });
 }