Hi,
I do not know how this exception is coming when calling the test case.
I do not have any Isolate.Verify.WasCalledWithArguments in the method.
My sample code:
[TestMethod]
public void TraceCachingManager_Cache_HttpContext_Test1()
{
Mock configurationManagerMock = MockManager.Mock(typeof(ConfigurationManager));
NameValueCollection customSettings = new NameValueCollection();
customSettings.Add("LogLastTenSqlTraces", "true");
configurationManagerMock.CallStatic.Clear();
configurationManagerMock.CallStatic.ExpectGetAlways("AppSettings", customSettings);
Isolate.WhenCalled(() => HttpContext.Current).ReturnRecursiveFake();
IDictionary dictionary = new AdapterDictionary();
Isolate.WhenCalled(() => HttpContext.Current.Items).WillReturn(dictionary);
string testCachedKey = "SqlCommandsKey";
Command command = new Command("up_api_AuthorisedUserGet", CommandType.SqlStoredProcedure);
command.Parameters.Add(new CommandParameter("@iUserId", 1));
command.Parameters.Add(new CommandParameter("@iCustomerId", 11209));
Isolate.WhenCalled(() => TraceCachingManager.AddItem(null, (Command)null)).CallOriginal();
TraceCachingManager.AddItem(testCachedKey, command);
string[] array = new string[1];
HttpContext.Current.Items.Keys.CopyTo(array, 0);
// Assert
Assert.AreEqual("SqlCommandsKey", array[0]);
}
it is erroring out in this first method of the class but all other methods passed.
I can see other methods do call the verify method but those are passed and it is unusual that it states error in the method which i do not have that syntax.
when i run individually it is passed but whole test in the project it fails.
For your reference the sample method which call Isolate.Verify.WasCalledWithArguments
[TestMethod]
public void Execute_With_Command_ThrowsException()
{
IDataProvider providerMock = Isolate.Fake.Instance<IDataProvider>();
ICommand commandMock = Isolate.Fake.Instance<ICommand>();
DataContext ctx = new DataContext(providerMock);
Isolate.WhenCalled(() => providerMock.Execute(null)).WillThrow(SqlHelper.CreateSqlException(1, "test proc"));
try
{
ResultSet rs = ctx.Execute(commandMock);
}
catch (SqlException ex)
{
bool knownError = false;
if (ex.Message == "Test Message")
{
knownError = true;
}
if (!knownError)
{
throw ex;
}
}
Isolate.Verify.WasCalledWithArguments(() => providerMock.Execute(commandMock));
}
Please help me out i could not able to get any clue