I have got a test to assert then when my application generates an application number(RHI), it asserts that the generated number on the final page is equal to the number in the db;
public void AssertRHINumberFromDB()
{
string rhiFromText = GenerateRHINumberIntoTextFile();
string query = "Select RHINumber from RHI.Application where RHINUMBER = 'rhiFromText'";
var rhiFromDB = Helper.ExecuteScalar(query);
Assert.Equals(rhiFromDB.Contains("RHINUMBER"), rhiFromText);
}
Though, when the ExecuteScalar
method goes, I am hit with Object Reference Error and rhiFromDB
is returning null.
relevant code:
public string GenerateRHINumberIntoTextFile()
{
var rhiPath = AppDriver.Driver.FindElement(By.CssSelector("#main-content>div>p:nth-child(2)>b"));
string generatedRHI = rhiPath.GetAttribute("innerText");
Helper.DeleteTextFilesAfterThreeMinutes();
Helper.WriteTextFile("TestFile1", generatedRHI);
return generatedRHI;
}
public static string ExecuteScalar(string command, SqlParameter[] parms = null)
{
using (ISQLService sql = new SQLService(new SqlConnection(ConfigurationManager.AppSettings["DBConnection"])))
{
return sql.ExecuteScalar(command, parms);
}
}
Any pointers?