title: NUnit Assert function to test if query executed successfully
body: <p>How to unit test a query with assert function? The below piece of code runs a query and I want to test the result with Assertion.</p>
  <pre><code>try
     {
       string query = &quot;SELECT \&quot;NAME\&quot;, \&quot;CITY\&quot;, \&quot;AGE\&quot; FROM MY_DB..EMPLOYEE&quot;;
       cmd.CommandText = query;
       dotNETDataReader rdr = cmd.ExecuteReader();
       while (rdr.HasRows)
         {
           rdr.Read();
           System.Console.WriteLine(rdr.GetString(0));
           System.Console.WriteLine(rdr.GetString(1));
           System.Console.WriteLine(rdr.GetInt32(2));
           Console.WriteLine(&quot;\t{0}\t{1}&quot;, rdr.GetValue(0), rdr.GetValue(1));
                      
         }
           rdr.Close();
           con.Close();
     }
     catch (Exception e)
     {
      System.Console.WriteLine(e.Message);
     }
         
  </code></pre>