summaryrefslogtreecommitdiffstats
path: root/tests/Cepis.Tests/NormalizeTests.cs
diff options
context:
space:
mode:
authorMurilo Ijanc <[email protected]>2026-07-26 12:42:38 -0300
committerMurilo Ijanc <[email protected]>2026-07-26 13:10:34 -0300
commita2b10fd494fb389e556e40134031eb86e56e11e7 (patch)
tree08b6df8a06f2c7c15488b90d57a6d8286cd57a22 /tests/Cepis.Tests/NormalizeTests.cs
downloadcsharp-a2b10fd494fb389e556e40134031eb86e56e11e7.tar.gz
Initial importv0.1.0
Diffstat (limited to 'tests/Cepis.Tests/NormalizeTests.cs')
-rw-r--r--tests/Cepis.Tests/NormalizeTests.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/Cepis.Tests/NormalizeTests.cs b/tests/Cepis.Tests/NormalizeTests.cs
new file mode 100644
index 0000000..3ff60cb
--- /dev/null
+++ b/tests/Cepis.Tests/NormalizeTests.cs
@@ -0,0 +1,35 @@
+namespace Cepis.Tests;
+
+/// <summary>Local validation, which happens before any request.</summary>
+public sealed class NormalizeTests
+{
+ [Theory]
+ [InlineData("01001000", "01001000")]
+ [InlineData("01001-000", "01001000")]
+ [InlineData(" 01001-000 ", "01001000")]
+ [InlineData("01.001-000", "01001000")]
+ [InlineData("01 001 000", "01001000")]
+ public void AcceptsTheMask(string input, string expected) =>
+ Assert.Equal(expected, CepisClient.NormalizeCep(input));
+
+ [Theory]
+ [InlineData("")]
+ [InlineData("0100100")]
+ [InlineData("010010000")]
+ [InlineData("0100100a")]
+ [InlineData("abcdefgh")]
+ [InlineData("01001-00")]
+ public void RejectsAnythingElse(string input) =>
+ Assert.Throws<InvalidCepException>(() => CepisClient.NormalizeCep(input));
+
+ [Fact]
+ public void RejectsNull() =>
+ Assert.Throws<InvalidCepException>(() => CepisClient.NormalizeCep(null!));
+
+ [Fact]
+ public void TheMessageCarriesWhatWasGiven()
+ {
+ var failure = Assert.Throws<InvalidCepException>(() => CepisClient.NormalizeCep("123"));
+ Assert.Contains("123", failure.Message, StringComparison.Ordinal);
+ }
+}