Skip to content

Commit 0e737c6

Browse files
committed
Add tests for hidden attribute and formula features
1 parent df5bb0b commit 0e737c6

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Tests/Tests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ public AutoFit() : this(null, null) { }
4545
public static AutoFit[] Values = new[] { new AutoFit("Short", "LongLongLongLongLongLong") };
4646
}
4747

48+
class Advanced
49+
{
50+
[Hidden]
51+
public int Hidden { get; set; }
52+
53+
public int Number => 2;
54+
55+
public string Formula => $"= {nameof(Number)} * {nameof(Number)}";
56+
57+
public static Advanced[] One = new[] { new Advanced() };
58+
}
59+
4860
[Layout(Flow.Horizontal)]
4961
class Horizontal { }
5062

@@ -374,5 +386,28 @@ public void Delete_IdentifiedByName_Works()
374386

375387
Assert.That(spreadsheet.Read<Simple>(k_NamedSheet), Is.Null);
376388
}
389+
390+
[Test]
391+
public void HiddenAttribute_Works()
392+
{
393+
using var spreadsheet = new Spreadsheet(k_SpreadsheetFilename);
394+
spreadsheet.Write(Advanced.One);
395+
396+
Assert.That(spreadsheet?.Document.GetCellValueAsString("A1"), Is.Not.EqualTo(nameof(Advanced.Hidden)));
397+
}
398+
399+
[Test]
400+
public void FormulaReferences_GetsReplacedByCellAddresses()
401+
{
402+
using var spreadsheet = new Spreadsheet(k_SpreadsheetFilename);
403+
spreadsheet.Write(Advanced.One);
404+
405+
Assert.Multiple(() =>
406+
{
407+
Assert.That(spreadsheet?.Document.GetCellValueAsString("A1"), Is.EqualTo(nameof(Advanced.Number)));
408+
Assert.That(spreadsheet?.Document.GetCellValueAsString("B1"), Is.EqualTo(nameof(Advanced.Formula)));
409+
Assert.That(spreadsheet?.Document.GetCellFormula("B2"), Contains.Substring("A2"));
410+
});
411+
}
377412
}
378413
}

0 commit comments

Comments
 (0)