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
Using the following code I expect the call to env.BuildSchema(fakeConn) to be ignored, instead this method is called with a null value?? Even when I configure the fakeDbConfig to return a recursive fake, still the GetConnection call returns a null value and env.BuildSchema does not get ignored.

        [Isolated]
        private static EnvironmentConfiguration GetEnvironmentConfiguration()
        {
            var fakeDbConfig = Isolate.Fake.Instance<IDatabaseConfig>();
            var fakeConn = Isolate.Fake.Instance<IDbConnection>();
            Isolate.WhenCalled(() => fakeDbConfig.GetConnection()).WillReturn(fakeConn);

            var fakeConfig = Isolate.Fake.Instance<Configuration>();
            var env = new EnvironmentConfiguration(TestEnv, fakeConfig, fakeDbConfig);

            Isolate.WhenCalled(() => env.BuildSchema(fakeConn)).WithExactArguments().IgnoreCall();
            return env;
        }


p.s. Also when I do

Isolate.WhenCalled(() => env.BuildSchema(fakeConn)).IgnoreCall();


the method still gets called, with a null value.
asked by halcwb (5.5k points)

1 Answer

0 votes
Oops found the mistake. Using ReSharper the method got automatically extracted with the Isolated attribute! This should be on the testmethod!

Then everything works as expected...
answered by halcwb (5.5k points)
...