chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
[TestClass]
    public class UnitTest1
    {
        public Array sample; 
        public Array copyTheArray( ref Array array1)
        {
            sample= array1;
            return sample;
 
        }
        public bool checkTheArray(Array array1, Array array2)
        {
            var dummy1 = copyTheArray(ref array1);
            var dummy2 = copyTheArray(ref array2);
            if (sample.Equals(array1))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        
 
        [TestMethod]
        public void TestcheckTheArray()
        {
            string[] sample1 = new string[] { "t", "s" };
            string[] sampleGroup = new string[]{"ts","pr","tp"};
            string[] sampleOriginal = new string[]{"p","s"}; 
            Array dummySample = null;
            sample = sampleOriginal;
            using (RecordExpectations recorder = new RecordExpectations())
            {
                recorder.DefaultBehavior.RepeatAlways();
                copyTheArray(ref dummySample);
                recorder.Return(sample);
            }
            var returnValue = checkTheArray(sample1, sampleGroup);
 
        }
    }
}
 
 
while running the above test, the second call to copyTheArray throws the exception
 
TypeMock Verification: Call to _2849.UnitTest1.copyTheArray() Parameter: 1
    expected: <"2 items">
     but was: <3>
 
1) Could anyone explain what is happening here? I undestand that the exception is for sending a different number of paramater, but I have'nt set the expected behavior to be like that.
2) what should be done to make the code to return the same value as like the one set in the recording block?
 
NB:- Please dont ask to use the new Typemock API as only this test case is failing and all other test are implemented with natural mocks.
Also this test start failing after update to 8.1.11
 
 
 

 

asked by thomasjohnaj (1.6k points)

1 Answer

0 votes
Thanks for reporting, this has been fixed and will be part of our next release
answered by eli (5.7k points)
...