File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments