Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Very strange problem - same code returns different resul
Message
De
12/03/2014 04:12:36
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Problèmes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01596181
Message ID:
01596205
Vues:
45
>Hi everybody,
>
>I am trying to debug code written by my colleague. He has a ValidationPass class that among other code has a reference to a different class with the following code:
>
>
>  protected Boolean ProcessDataTable(SqlCommand toSqlCommand)
>        {
>            using (SqlDataReader sqlDataReader = toSqlCommand.ExecuteReader())
>            {
>                table = new DataTable();
>                if (sqlDataReader.HasRows)
>                    table.Load(sqlDataReader);
>            }
>            return true;
>        }
>
>----------------------
>I have a test method that tests just this validation class. The code is the following:
>
>
>   [TestMethod][TestCategory("Validation")]
>      public void V_vpTestRealCardNo()
>      {
>         String cResult = "0-OK";
>         try
>         {
>            ValidationTestHelper vth = new ValidationTestHelper();
>             
>            vth.ValidationParameters["tcCardNo"] = "6035249990127572";      //"6035249990104324"; -- original value
>            ValidationPass vp = new ValidationPass(middlewareMain.database, vth.ValidationParameters);
>            cResult = vp.cPassNo;
>         }
>         catch (SiriusException sex)
>         {
>            cResult = String.Format("{0}-{1}", sex.statusCode, sex.Message);
>         }
>         String cExpected = "70031001"; //"15005001"; -- original value - pass no longer exists
>         Assert.IsTrue(String.Equals(cResult, cExpected, StringComparison.OrdinalIgnoreCase));
>      }
>
>This test works fine and I can debug it fine.
>
>Now, in a Validation class I have a method calling
>
>
> public String CheckCard(Dictionary<String, String> parameters)
>      {
>         Int32 index = this.CurrentRequest.StartMethod("CheckCard", 1);
>         String cResult = "";
>         try
>         {
>            ValidationPass vpOriginal   = new ValidationPass(this.database, parameters);
>            cResult = vpOriginal.FindValidPass();
>         }
>         catch (SiriusException sex)
>         {
>            cResult = 0.MTag("ERR") + sex.statusCode.MTag("StatusCode") + sex.Message.MTag("MSG");
>         }
>         this.CurrentRequest.FinishMethod(index, 2);
>         return cResult;
>      }
>
>and when I trace it I'm getting dataReader.HasRows = false for exactly the same SqlCommand and same parameter that is used in the first test.
>
>Also, I am not sure how to exactly check the parameter while I am debugging it - it doesn't seem to expand to the value when I check that SqlCommand passed.
>
>In any case, do you see what I may be missing and why the same code returns 1 row of data in the first case and 0 rows in the second case?

Impossible to tell what's going on from the code that you posted since neither method directly calls the ProcessDataTable() method. But 'exact same code' will produce the same result so you've got a difference somewhere :-}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform