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

I have the following class 

 public class ExampleClass : ClassBase
    {
        private readonly Service _service;


        public ExampleClass()
            : base("Sync")
        {
            _service = new Service(_log);
        }

        protected override void ExecuteProcess()
        {
            var request = Transfer.RequestParameters;
            _service.SyncMethod(request);
        }
    }

 

I' trying to fake and swap the private readonly Service _service; because I want to ignore the call to _service.SyncMethod(request).
 
[ExpectedException(typeof(WebException))]
        public void ShouldSubscriberSynchronizeExecuteInternal()
        {
            ExampleClass Trx = ExampleClass ();
            Service faked = Isolate.Fake.Instance<Service >(Members.ReturnRecursiveFakes, ConstructorWillBe.Called);
            Isolate.Swap.NextInstance<Service >().With(faked);
            Isolate.WhenCalled(() => faked.SyncMethod(null)).IgnoreCall();

            //Reflection is used to invoke private method
            var method = typeof(ExampleClass ).GetMethod("ExecuteProcess"
                , BindingFlags.NonPublic | BindingFlags.Instance);

            method.Invoke(Trx, null);
        }

 

 
Any way I just want to ignore SyncMethod, somebody has an idea who I can do that?
asked by ronald.saborio (600 points)

Please log in or register to answer this question.

...