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
I am feeding a fake to an instance of class under test which sets properties on the fake and then makes an inner call, again setting properties. Only the properties in the outer call are persisted unless I explicitly set ReturnRecursiveFakes on the property.

Setting Members behavior in constructor has no effect so does this mean that I must explicitly set recursive fake on any property that I expect to be set more than one call deep?

In any case, I was unable to find any references to this kind of behavior in the documentation and the behavior illustrated by the code below is unintuitive.

Am I missing something?

using NUnit.Framework;
using TypeMock.ArrangeActAssert;

namespace Test
{
    public interface IFakeObject
    {
        string Property { get; set; }
    }

    public class ClassUnderTest
    {
        public void Outer(IFakeObject fakeObject)
        {
            fakeObject.Property = "Outer";
            Inner(fakeObject);
        }

        private void Inner(IFakeObject fakeObject)
        {
            fakeObject.Property = "Inner";
        }
    }

    [TestFixture]
    public class TypeMockTest
    {
        [Test, Isolated]
        public void TestPropSetterVsCallDepth()
        {
            ClassUnderTest cut = new ClassUnderTest();


            IFakeObject fakeObject1 = Isolate.Fake.Instance<IFakeObject>();
            cut.Outer(fakeObject1);
            // is 'Outer' but should be 'Inner'? Fake only accepts property sets one call deep
            Assert.AreEqual("Outer", fakeObject1.Property);


            // set Members.ReturnRecursiveFakes
            IFakeObject fakeObject2 = Isolate.Fake.Instance<IFakeObject>(Members.ReturnRecursiveFakes);
            cut.Outer(fakeObject2);
            // is 'Outer' but should be 'Inner'? Fake only accepts property sets one call deep
            // even with Members.ReturnRecursiveFakes
            Assert.AreEqual("Outer", fakeObject2.Property);


            IFakeObject fakeObject3 = Isolate.Fake.Instance<IFakeObject>();
            // set a recursive fake on the property itself
            Isolate.WhenCalled(() => fakeObject3.Property).ReturnRecursiveFake();
            cut.Outer(fakeObject3);

            //Finally, is Inner
            Assert.AreEqual("Inner", fakeObject3.Property);
        }
    }
}
asked by bitPusher (760 points)

8 Answers

0 votes
Hi,

Which version of Isolator are you using?

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
Hi,

Which version of Isolator are you using?

Regards,
Elisha,
Typemock Support


V 5.4.5, VS2008TS, Win7x64, AnyCPU
answered by bitPusher (760 points)
0 votes
Hi,

I believe we managed to fix this issue, so I'm sending you a patched version. Please let me know if the issue is resolved.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Appears to pass the tests.
Thanks for the prompt action.

Seems not so obscure - I am I the only person who tests call stacks deeper than 1?

Was this a new issue or regression?
answered by bitPusher (760 points)
0 votes
After installing the new build code editor is unbearably slow?

Am on a quick machine with a fresh SSD and typically enjoy very little friction.

Do you see the same?
answered by bitPusher (760 points)
0 votes
Try removing Typemock productivity - do you still have a performance issue?
answered by dhelper (11.9k points)
0 votes
a little better.

to be fair - i do run coderush and resharper. i have spent many hours getting coderush and resharper to play nicely with one another generally experience little friction. I guess one more is just too much.
answered by bitPusher (760 points)
0 votes
Amazing - I didn't know you can run CodeRush and R# at the same time.

Obviously our Productivity tool will add some more overhead to both these tools, although I still recommend using it, it has a low overhead and can improve your test writing experience.
answered by dhelper (11.9k points)
...