I'm trying to get a Session Timeout when I call on a certain Stored Procedures in my DB (the return code for this in my DB is 3). I wanna do that so that I can make a successful Assertion to my DB. I tried putting the thread to sleep for a couple of minutes but I'm sure there is a more practical (faster) way to get a Session Timeout error.
The following code is to assert an "Invalid Session" return code (that is 2) I wanna do something similar to get a 3 (Session timeout) as a return code.
[Test, Description("Tests Possible Return Codes for the AcquireChangeLock SP")]
public void test_invalidSession()
{
//Method to generate a valid Session Id
int sessionId = src.run_Session_Logon_SP(dataSource, initialCataloge);
//Generate a random no. and add it to the
//retrieved sessionId to get an invalid sessionId
Guid screw = Guid.NewGuid();
byte[] _bytes = screw.ToByteArray();
int k = ((int)_bytes[0]) | ((int)_bytes[1] << 8) | ((int)_bytes[2]);
sessionId += k;
//List with all the Tables and their Guids in the DB
lst_objectName_Guid = src.getObjectName_Guid(direct);
for (int i = 0; i < lst_objectName_Guid.Count; i += 2)
{
objectName = lst_objectName_Guid[i]; //Get the objectName values from the Even Indexes
oGuid = lst_objectName_Guid[i + 1]; //Get the Guid valuees from the Odd Indexes
final_oGuid = new Guid(oGuid);
Console.WriteLine(objectName);
//Method that generate Return Codes
int code = src.run_AcquireChangeLock_SP(dataSource, initialCataloge, sessionId, objectName, final_oGuid);
Assert.AreEqual(2, code);
src.run_ReleaseChangeLock_SP(dataSource, initialCataloge, sessionId, objectName, final_oGuid);
}
}