ExisteMovimientosArticuloTest.cs
1 using System;
3 using Microsoft.VisualStudio.TestTools.UnitTesting;
4 using Sage.ES.S50.UnitTest.Tools;
5 
6 
7 namespace Sage.ES.S50.UnitTest.addons.idatos
8 {
9  [TestClass]
11  {
12  #region Properties
13  private TestContext testContextInstance;
14 
19  public TestContext TestContext
20  {
21  get
22  {
23  return testContextInstance;
24  }
25  set
26  {
27  testContextInstance = value;
28  }
29  }
30  #endregion Properties
31 
32  #region Members
33 
34  private ImportacionArticulos _ImportArticulos = new ImportacionArticulos();
35  private PrivateObject obj;
36  #endregion
37 
38 
39  #region Initialize
40  //
41  //You can use the following additional attributes as you write your tests:
42  //
43  //Use ClassInitialize to run code before running the first test in the class
44  [ClassInitialize()]
45  public static void MyClassInitialize(TestContext testContext)
46  {
47  //Conexion a Base de Datos
48  testContext.__Test_LoadRandomConfig();
49  }
50 
51  [TestInitialize]
52  public void MyTestInitialize()
53  {
54  _ImportArticulos = new ImportacionArticulos();
55  obj = new PrivateObject(_ImportArticulos);
56  }
57 
58  #endregion
59 
60  #region Test Methods
61  [Owner(Owners.Luisa_Galvan), TestMethod()]
62  [Priority(1)]
63  [DataRow("D_ALBCOM", "ART1", false)]
64  [DataRow("C_PROD", "ART1", false)]
65  public void MovimientosArticuloTest(string tabla, string articulo, bool expected)
66  {
67  try
68  {
69  bool result = (bool)obj.Invoke("ExisteMovimientosArticulo", new object[] { tabla, articulo });
70  if (result)
71  {
72  Assert.IsTrue(!expected, $"Existe movimentos del artículo {articulo} en la tabla {tabla}");
73  }
74  else
75  {
76  Assert.AreEqual(result, expected, $"Se esperaba un {expected}");
77  }
78  }
79  catch(Exception e)
80  {
81  Assert.Fail($"Excepción lanzada que no se esperaba. {e.Message}");
82  }
83  }
84  #endregion
85  }
86 }
void MovimientosArticuloTest(string tabla, string articulo, bool expected)