1
1
using System ;
2
2
using System . Text ;
3
- using System . Collections . Generic ;
4
- using SW . Helpers ;
5
3
using SW . Services . Validate ;
6
4
using Test_SW . Helpers ;
7
5
using Microsoft . VisualStudio . TestTools . UnitTesting ;
@@ -19,9 +17,35 @@ public void ValidateXML_UT_Ok()
19
17
Validate validate = new Validate ( build . Url , build . User , build . Password ) ;
20
18
var xml = GetXml ( build ) ;
21
19
ValidateXmlResponse response = validate . ValidateXml ( xml . ToString ( ) ) ;
22
- Assert . IsTrue ( response . status == "success"
23
- && ! string . IsNullOrEmpty ( response . statusCodeSat ) , "N - 601: La expresión impresa proporcionada no es válida." ) ;
20
+ Assert . IsTrue ( response . status == "success" ) ;
21
+ Assert . IsTrue ( response . statusSat == "Vigente" ) ;
22
+ Assert . IsTrue ( response . statusCodeSat == "S - Comprobante obtenido satisfactoriamente" ) ;
24
23
}
24
+
25
+ [ TestMethod ]
26
+ public void ValidateXML_UT_Ok_With_Status ( )
27
+ {
28
+ var build = new BuildSettings ( ) ;
29
+ Validate validate = new Validate ( build . Url , build . User , build . Password ) ;
30
+ var xml = GetXml ( build ) ;
31
+ ValidateXmlResponse response = validate . ValidateXml ( xml . ToString ( ) , true ) ;
32
+ Assert . IsTrue ( response . status == "success" ) ;
33
+ Assert . IsTrue ( response . statusSat == "Vigente" ) ;
34
+ Assert . IsTrue ( response . statusCodeSat == "S - Comprobante obtenido satisfactoriamente" ) ;
35
+ }
36
+
37
+ [ TestMethod ]
38
+ public void ValidateXML_UT_Ok_Without_Status ( )
39
+ {
40
+ var build = new BuildSettings ( ) ;
41
+ Validate validate = new Validate ( build . Url , build . User , build . Password ) ;
42
+ var xml = GetXml ( build ) ;
43
+ ValidateXmlResponse response = validate . ValidateXml ( xml . ToString ( ) , false ) ;
44
+ Assert . IsTrue ( response . status == "success" ) ;
45
+ Assert . IsTrue ( response . statusSat == "No Aplica" ) ;
46
+ Assert . IsTrue ( response . statusCodeSat == "No Aplica" ) ;
47
+ }
48
+
25
49
[ TestMethod ]
26
50
public void Validate_Test_ValidateXMLError ( )
27
51
{
@@ -32,10 +56,10 @@ public void Validate_Test_ValidateXMLError()
32
56
Assert . IsTrue ( response . status == "error"
33
57
&& ! string . IsNullOrEmpty ( response . status ) , "Error al leer el documento XML. La estructura del documento no es un Xml valido y/o la codificación del documento no es UTF8. Root element is missing." ) ;
34
58
}
59
+
35
60
private object GetXml ( BuildSettings build )
36
61
{
37
- var xml = Encoding . UTF8 . GetString ( File . ReadAllBytes ( "Resources/cfdi40.xml" ) ) ;
38
- xml = SignTools . SigXml ( xml , Convert . FromBase64String ( build . Pfx ) , build . PfxPassword ) ;
62
+ var xml = Encoding . UTF8 . GetString ( File . ReadAllBytes ( "Resources/cfdi40_stamp.xml" ) ) ;
39
63
return xml ;
40
64
}
41
65
}
0 commit comments