Пример #1
0
        private object CreateMockRemoted(Type type)
        {
            var instance         = new MockInstance(new Type[0]);
            var proxyInterceptor = new ProxyInterceptor(instance);

            var generator = new RepositoryForRemoting();
            var proxy     = generator.CreateMockRemoting(type, proxyInterceptor, instance);

            instance.ProxyInstance = proxy;
            return(proxy);
        }
Пример #2
0
        private static IMockExpectationContainer GetExpectationContainer(object instance)
        {
            if (typeof(Delegate).IsAssignableFrom(instance.GetType()))
            {
                var instanceDelegate = (Delegate)instance;
                instance = instanceDelegate.Target;
            }

            if (instance is IMockExpectationContainer)
            {
                return(instance as IMockExpectationContainer);
            }

            if (RepositoryForRemoting.IsRemotingProxy(instance))
            {
                var proxiedInstance = RepositoryForRemoting
                                      .GetMockedInstanceFromProxy(instance);

                return(proxiedInstance as IMockExpectationContainer);
            }

            return(null);
        }