28 lines
790 B
C#
28 lines
790 B
C#
using KronaStaffTerminal.Services;
|
|
using Xunit;
|
|
|
|
namespace KronaStaffTerminal.Tests;
|
|
|
|
public sealed class CsvCellEncoderTests
|
|
{
|
|
[Theory]
|
|
[InlineData("=HYPERLINK(\"https://example.invalid\")")]
|
|
[InlineData("+cmd")]
|
|
[InlineData("-1+1")]
|
|
[InlineData("@SUM(A1:A2)")]
|
|
[InlineData(" =SUM(A1:A2)")]
|
|
[InlineData("\t=SUM(A1:A2)")]
|
|
[InlineData("\r=SUM(A1:A2)")]
|
|
public void Encode_neutralizes_spreadsheet_formulas(string value)
|
|
{
|
|
var encoded = CsvCellEncoder.Encode(value);
|
|
|
|
Assert.StartsWith("\"'", encoded);
|
|
}
|
|
|
|
[Fact]
|
|
public void Encode_preserves_regular_unicode_and_escapes_quotes()
|
|
{
|
|
Assert.Equal("\"Иван \"\"Повар\"\"; смена\"", CsvCellEncoder.Encode("Иван \"Повар\"; смена"));
|
|
}
|
|
}
|