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
Hi, I have two classes
    public class ClassSim
    {
        public void DoNothing()
        {

        }

        public ClassSim()
        {

        }
    }

    public class ClassComp
    {
        public ClassSim sim=new ClassSim();
        public ClassComp()
        {
            sim=new ClassSim();
        }
        public void CallClassSim()
        {
            //sim = new ClassSim();
            sim.DoNothing();
        }
    }


I found that this test
        [Test]
        [Isolated]
        public void TestNest()
        {
            ClassComp compFake = Isolate.Fake.Instance<ClassComp>(Members.CallOriginal);
            ClassSim simFake = Isolate.Fake.Instance<ClassSim>();
            Isolate.WhenCalled(()=>compFake.sim).WillReturn(simFake);

        }

will return an exception. I don't think this is the valid behavior because if I change sim from variable type to a property type, then the test will run just fine :D
________
Mercedes-Benz W221 specifications
asked by nsoonhui (59.1k points)

5 Answers

0 votes
Hi,

just wonder whether is public members mockable in the next AAA release?
________
glass weed pipe
answered by nsoonhui (59.1k points)
0 votes
Hi Soon,

No, mocking fields is not planned for this release. But why not just set the field? You don't need faking to do this.

Thanks,
answered by gilz (14.5k points)
0 votes
Hi Soon,

No, mocking fields is not planned for this release. But why not just set the field? You don't need faking to do this.

Thanks,


Good idea! Thanks
________
herbal vaporizers
answered by nsoonhui (59.1k points)
0 votes
Hi Soon,

No, mocking fields is not planned for this release. But why not just set the field? You don't need faking to do this.

Thanks,


On a second thought, being able to mock private method is tremendously useful.
________
buy vapor genie
answered by nsoonhui (59.1k points)
0 votes
On a second thought, mocking private members are tremendously useful.
________
BIG TITS VIDS
answered by nsoonhui (59.1k points)
...