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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
try the below production code:
    public interface BuildInterface
    {
        bool CanContinue(out string str);
    }

    public class TestBuildInterface
    {
        public BuildInterface build
        { get; private set; }
        public TestBuildInterface(BuildInterface bb)
        {
            build = bb;
        }

        public int Looping()
        {
            for (int i = 0; i < 10; i++)
            {
                string str;
                if(!build.CanContinue(out  str))
                    return i;
            }
            return -1;
        }
    }


and the following test code
        [Test]
        public void TestBuildtest()
        {
            var build = Isolate.Fake.Instance<BuildInterface>();
            var str = "";
            Isolate.WhenCalled(()=>build.CanContinue(out str))
                .WillReturn(true);
            Isolate.WhenCalled(() => build.CanContinue(out str))
            .WillReturn(false);

            var buildTest = new TestBuildInterface(build);
            var loopInt = buildTest.Looping();
            Assert.AreEqual(1, loopInt);
        }


The test fails, even though it should
________
Yamaha gx1
asked by nsoonhui (59.1k points)

9 Answers

0 votes
Hi Soon Hui,

I've tried to reproduce this issue on my local machine but the test passed.

What version of VS are you using? I've used VS2008 on a 64 bit machine.

Can you send a repro project to typemock support?
answered by dhelper (11.9k points)
0 votes
Hello,

I am using VS 2008 32 bit Windows XP, with NUnit.

It is just a very simple repro test case which I can repro in a small example, as posted above.

I will send you the project if you can't repro it in VS 2008 Windows XP.
________
Daihatsu Applause
answered by nsoonhui (59.1k points)
0 votes
Soon Hui,

This does not recreate with our latest internal build. I'll send you a patched version by email - please let me know if that resolved the issue.

Thanks,
Doron
Typemock Support
answered by doron (16.5k points)
0 votes
Hi,

your latest build still fails. Can it be a protection issue?
________
PUBLIC STREET
answered by nsoonhui (59.1k points)
0 votes
Hi Soon Hui,

I can confirm this is a bug, but it doesn't happen because of the interface. The issue is with sequencing behavior on calls that receive a ref or out parameter.

We'll work on fixing the bug and update here when it's resolved.

Doron
Typemock Support
answered by doron (16.5k points)
0 votes
I'm having the same problem. When do you expect to have a fix (or patch) released?

Thanks,

Darin
answered by Darin_Creason (3.5k points)
0 votes
I am running into this issue as well. I am testing a method that makes a call to an interface method that has out parameters. I would like to specify what gets returned in the out parameters as well as the return value from the interface method.

Thanks,
Brian
answered by bhunter (3.4k points)
0 votes
Brian,

Are you sequencing calls on the method with the out parameter, or just setting expectations? Can you post some sample test code of what you're trying to do?

Thanks,
Doron
Typemock Support
answered by doron (16.5k points)
0 votes
Disregard my post. I realized what I was doing incorrectly when arranging my unit test.
answered by bhunter (3.4k points)
...