Unable to mock the ref and out parameter of the function, test case fails occasionally.
Sample code:
Test case:
public void test1()
{
string expected = null;
string s1 ="hi";
string s2="hello";
string xpected = "pound";
string key = "Test";
langType ret_lang = langType.English;
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
string Lang = privateTarget.CLanguage(ref key, ref ret_lang);
recorder.Return("pound").RepeatAlways();
}
privateTarget.CLa(key, ref s1, ref s2);
Assert.AreEqual(expected, s1, "s1_CLa_expected was not set correctly.");
Assert.AreEqual(xpected, s2, "s2_CLa_expected was not set correctly.");
}
Public void CLa(key, ref s1, ref s2)
{
s1 = null
s2= null
...
..........
string key = "Mother Tongue"
langType ret_lang = langType.French;
string st = CLanguage(key, ref ret_lang);
....
...
If ret_lang = French Then
s1 = st
Else
s2 = st
Endif
.....
}
When the test case fails the ret_Lang = French. Thus mocking the ref and out parameter fails occassionally.
I have tried the dynamic mocking but still the test case fails ocassionally.
I am not able to make the test case pass consistently.
Typemock.NET version 4.1.0.0
The Testcase is in C#.Net and the
Function is in VB.Net
Please help me out to resolve this issue.
Thanks in advance.