mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-07-08 18:16:08 +00:00
Matches Excel terminology, OpenXML spec, and industry convention (Aspose, Telerik, Syncfusion all use Worksheet). Property names on components remain Sheet for now; only the type name changes.
70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using System;
|
|
using Xunit;
|
|
|
|
using Radzen.Documents.Spreadsheet;
|
|
namespace Radzen.Blazor.Spreadsheet.Tests;
|
|
|
|
public class CellStoreTests
|
|
{
|
|
readonly CellStore cellStore = new(new Worksheet(5, 5));
|
|
|
|
[Fact]
|
|
public void CellStore_ShouldReturnNewCell_WhenCellDoesNotExist()
|
|
{
|
|
var cell = cellStore[0, 0];
|
|
|
|
Assert.NotNull(cell);
|
|
}
|
|
|
|
[Fact]
|
|
public void CellStore_ShouldThrowArgumentOutOfRangeException_WhenRowExceedsMax()
|
|
{
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => cellStore[5, 0]);
|
|
}
|
|
|
|
[Fact]
|
|
public void CellStore_ShouldThrowArgumentOutOfRangeException_WhenColumnExceedsMax()
|
|
{
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => cellStore[0, 5]);
|
|
}
|
|
|
|
[Fact]
|
|
public void CellStore_ShouldReturnExistingCell_WhenCellExists()
|
|
{
|
|
var expectedCell = new Cell(cellStore.Worksheet, new CellRef(0, 0));
|
|
cellStore[0, 0] = expectedCell;
|
|
var cell = cellStore[0, 0];
|
|
Assert.Same(expectedCell, cell);
|
|
}
|
|
|
|
[Fact]
|
|
public void CellStore_ShouldReturnExistingCell_ViaA1Notation()
|
|
{
|
|
var expectedCell = new Cell(cellStore.Worksheet, new CellRef(0, 0));
|
|
|
|
cellStore[0, 0] = expectedCell;
|
|
|
|
var cell = cellStore["A1"];
|
|
|
|
Assert.Same(expectedCell, cell);
|
|
}
|
|
|
|
[Fact]
|
|
public void CellStore_ShouldThrowException_WhenInvalidA1Notation()
|
|
{
|
|
Assert.Throws<ArgumentException>(() => cellStore["Invalid"]);
|
|
}
|
|
|
|
[Fact]
|
|
public void CellStore_ShouldSupport_MultipleLettersInA1Notation()
|
|
{
|
|
var cellStore = new CellStore(new Worksheet(5, 30));
|
|
var expectedCell = new Cell(cellStore.Worksheet, new CellRef(0, 26));
|
|
|
|
cellStore[0, 26] = expectedCell;
|
|
|
|
var cell = cellStore["AA1"];
|
|
|
|
Assert.Same(expectedCell, cell);
|
|
}
|
|
} |