From 39772a96a029ef30d82ed525dc2ecf31fb7701d8 Mon Sep 17 00:00:00 2001 From: sveinungf Date: Sat, 4 Nov 2023 21:34:13 +0100 Subject: [PATCH] Test for invalid note references --- .../Tests/SpreadsheetNoteTests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/SpreadCheetah.Test/Tests/SpreadsheetNoteTests.cs b/SpreadCheetah.Test/Tests/SpreadsheetNoteTests.cs index ad04c50d..37a06325 100644 --- a/SpreadCheetah.Test/Tests/SpreadsheetNoteTests.cs +++ b/SpreadCheetah.Test/Tests/SpreadsheetNoteTests.cs @@ -156,6 +156,25 @@ public async Task Spreadsheet_AddNote_ThrowsOnTooLongText(int textLength, bool e Assert.Equal(exceptionExpected, exception is ArgumentException); } + [Theory] + [InlineData(null)] + [InlineData("")] + [InlineData(" ")] + [InlineData("A")] + [InlineData("A0")] + [InlineData("A1:A2")] + [InlineData("$A$1")] + public async Task Spreadsheet_AddNote_InvalidReference(string reference) + { + // Arrange + using var stream = new MemoryStream(); + await using var spreadsheet = await Spreadsheet.CreateNewAsync(stream); + await spreadsheet.StartWorksheetAsync("Sheet"); + + // Act & Assert + Assert.ThrowsAny(() => spreadsheet.AddNote(reference, "My note")); + } + [Theory] [InlineData("A1", "1.2pt")] [InlineData("A2", "8.4pt")]