Skip to content

Commit 08abbdd

Browse files
authored
Merge pull request #2 from VARPERTechnologies/new-test-cases
New test cases
2 parents 8d6653f + 2775bfd commit 08abbdd

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using NUnit.Framework;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Vpt.Chile.Identity.Exceptions;
8+
9+
namespace Vpt.Chile.Identity.Test
10+
{
11+
public class CastingTest
12+
{
13+
[TestCase("12345678-6", Reason = "Throws exception due incorrect verifier digit")]
14+
public void CastingFromStringExceptions(string input)
15+
{
16+
//Arrange
17+
//Act
18+
//Assert
19+
Assert.Throws<RutException>(() => { RUT rut = input; });
20+
}
21+
22+
[Test]
23+
public void CastingFromNullStringExceptions()
24+
{
25+
//Arrange
26+
string input = null;
27+
//Act
28+
//Assert
29+
Assert.Throws<ArgumentNullException>(() => { RUT rut = input; });
30+
}
31+
32+
[Test]
33+
public void CastingToString()
34+
{
35+
//Arrange
36+
var rut = new RUT(12345678, '5');
37+
38+
//Act
39+
string actual = rut;
40+
41+
//Assert
42+
Assert.AreEqual("12345678-5", actual);
43+
}
44+
}
45+
}

Vpt.Chile.Identity/RUT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public RUT(uint Numero, char DigitoVerificador)
3838
public static RUT FromString(string rut)
3939
{
4040
//TODO: Overload this function to support custom rut formats
41-
if (string.IsNullOrEmpty(rut)) throw new ArgumentNullException($"Argumento {nameof(rut)} no puede ser nulo o vacio");
41+
if (string.IsNullOrEmpty(rut)) throw new ArgumentNullException($"{nameof(rut)} no puede ser nulo o vacio");
4242
string notaInitial = "La cadena no contiene un Rut valido";
4343
string[] rutParts = rut.Split('-');
4444
uint numero = 0;

0 commit comments

Comments
 (0)