CuentaPresupuestariaTest.cs
1 using System;
3 using Microsoft.VisualStudio.TestTools.UnitTesting;
4 using System.Data;
5 using System.Collections.Generic;
6 using System.IO;
7 using sage.ew.db;
8 using Sage.ES.S50.UnitTest.Tools;
10 using Newtonsoft.Json.Linq;
11 using static System.Net.WebRequestMethods;
12 
13 namespace Sage.ES.S50.UnitTest.addons.idatos
14 {
18  [TestClass()]
19  [DeploymentItem(@"Idatos\", "Idatos")]
20  public class CuentaPresupuestariaTest
21  {
22  #region Properties
23  private TestContext testContextInstance;
24 
29  public TestContext TestContext
30  {
31  get
32  {
33  return testContextInstance;
34  }
35  set
36  {
37  testContextInstance = value;
38  }
39  }
40  #endregion Properties
41 
42  #region Additional test attributes
43  //
44  //You can use the following additional attributes as you write your tests:
45  //
46  //Use ClassInitialize to run code before running the first test in the class
47  [ClassInitialize()]
48  public static void MyClassInitialize(TestContext testContext)
49  {
50  //Conexion a Base de Datos
51  testContext.__Test_LoadRandomConfig();
52  }
53 
54  #endregion
55 
56  [Owner(Owners.Luisa_Galvan), TestMethod()]
57  [Priority(1)]
58  public void CrearCuentaPresupuestaria_IdatosTest()
59  {
60  #region DATOS INPUT
61 
62  DataTable ldtCuentas = new DataTable();
63  ldtCuentas.Clear();
64  ldtCuentas.Columns.Add("codigo", typeof(string));
65  ldtCuentas.Columns.Add("nombre", typeof(string));
66 
67  DataRow ldr = ldtCuentas.NewRow();
68  ldr["codigo"] = "44440001";
69  ldr["nombre"] = "presupuestaria 01";
70  ldtCuentas.Rows.Add(ldr);
71 
72  ldr = ldtCuentas.NewRow();
73  ldr["codigo"] = "00000002";
74  ldr["nombre"] = "presupuestaria 02";
75  ldtCuentas.Rows.Add(ldr);
76 
77  ldr = ldtCuentas.NewRow();
78  ldr["codigo"] = "04";
79  ldr["nombre"] = "presupuestaria 04";
80  ldtCuentas.Rows.Add(ldr);
81 
82  ldr = ldtCuentas.NewRow();
83  ldr["codigo"] = "05";
84  ldr["nombre"] = "presupuestaria 05";
85  ldtCuentas.Rows.Add(ldr);
86 
87  ldr = ldtCuentas.NewRow();
88  ldr["codigo"] = "06";
89  ldr["nombre"] = "presupuestaria 06";
90  ldtCuentas.Rows.Add(ldr);
91 
92 
93 
94  DataTable ldtReferencias = new DataTable();
95  ldtReferencias.Clear();
96  ldtReferencias.Columns.Add("idtabla", typeof(int));
97  ldtReferencias.Columns.Add("cuenta", typeof(string));
98  ldtReferencias.Columns.Add("referencia", typeof(string));
99  ldtReferencias.Columns.Add("filaCSV", typeof(int));
100 
101  #endregion
102 
103  ImportacionContaPresup loCuentaPresup = new ImportacionContaPresup();
104  PrivateObject importacionPO = new PrivateObject(loCuentaPresup);
105 
106  PrivateType pt = new PrivateType(typeof(ImportacionBase));
107  pt.SetStaticFieldOrProperty("dtCuentaRef", ldtReferencias);
108 
109  importacionPO.SetFieldOrProperty("dtAuxCuentas", ldtCuentas);
110 
111  try
112  {
113  loCuentaPresup.CrearCuentaPresupuestaria(1, "40000001");
114  }
115  catch(Exception e)
116  {
117  Assert.IsFalse(false, "No se han creado registro en tabla" + e.Message);
118  }
119 
120  Assert.IsTrue(true, "Ha pasado el test unitario");
121 
122  }
123  }
124 }