Skip to content

Commit 1829b61

Browse files
Added test & formal changes
1 parent 5c0e414 commit 1829b61

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

NanoXLSX.Core/Interfaces/Reader/IPluginBaseReader.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
using System;
9-
using System.CodeDom.Compiler;
109
using System.IO;
1110

1211
namespace NanoXLSX.Interfaces.Reader

NanoXLSX.Core/Interfaces/Reader/IPluginPackageReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace NanoXLSX.Interfaces.Reader
99
{
1010
/// <summary>
11-
/// Interface, used by ipackage reader plug-ins
11+
/// Interface, used by package reader plug-ins
1212
/// </summary>
1313
internal interface IPluginPackageReader : IPluginQueueReader
1414
{

NanoXLSX.Core/Interfaces/Reader/IPluginReader.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
* You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
66
*/
77

8-
using System;
9-
using System.IO;
10-
118
namespace NanoXLSX.Interfaces.Reader
129
{
1310
/// <summary>

NanoXLSX.Core/Worksheet.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,13 @@ public void AddCellRange(IReadOnlyList<object> values, Range cellRange, Style st
989989
/// <param name="style">Style to apply on the all cells of the range</param>
990990
/// \remark <remarks>The data types in the passed list can be mixed. Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool.
991991
/// All other types will be cast into a string using the default ToString() method</remarks>
992-
/// <exception cref="RangeException">Throws a RangeException if the number of cells differs from the number of passed values</exception>
992+
/// <exception cref="RangeException">Throws a RangeException if the passes list is null or the number of cells differs from the number of passed values</exception>
993993
private void AddCellRangeInternal<T>(IReadOnlyList<T> values, Address startAddress, Address endAddress, Style style)
994994
{
995+
if (values == null)
996+
{
997+
throw new RangeException("The passed value list cannot be null");
998+
}
995999
List<Address> addresses = Cell.GetCellRange(startAddress, endAddress) as List<Address>;
9961000
if (values.Count != addresses.Count)
9971001
{

NanoXlsx.Core.Test/Worksheets/AddCellRangeTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ public void AddCellRangeFailingTest2(string givenRange, string falseRange, Range
229229
Assert.Throws<RangeException>(() => worksheet.AddCellRange(data.Values, falseRange));
230230
}
231231

232+
[Fact(DisplayName = "Test of the failing AddCellRange function with a null as passed list")]
233+
public void AddCellRangeFailingTest3()
234+
{
235+
NanoXLSX.Range cellRange = "A1:A1";
236+
Worksheet worksheet = new Worksheet();
237+
Assert.Empty(worksheet.Cells);
238+
Assert.Throws<RangeException>(() => worksheet.AddCellRange(null, cellRange));
239+
}
232240

233241
private void AssertRange(Worksheet worksheet, ListTuple expectedData)
234242
{

0 commit comments

Comments
 (0)