コード例 #1
0
        public object CreateMock(Type mockType)
        {
            var interceptor = new MockInterceptor(invocationDescriptorFactory, invocationTransformer, invocationStage, invocationOperationManagerFinder);
            var mock        = proxyGenerator.CreateInterfaceProxyWithoutTarget(mockType, interceptor);

            interceptor.SetMock(mockType, mock);
            return(mock);
        }
コード例 #2
0
        public T CreateSpy <T>() where T : class
        {
            var interceptor = new MockInterceptor(invocationDescriptorFactory, invocationTransformer, invocationStage, invocationOperationManagerFinder);
            T   target      = (T)Activator.CreateInstance(typeof(T));
            var mock        = proxyGenerator.CreateClassProxyWithTarget(target, interceptor);

            interceptor.SetMock(typeof(T), mock);
            interceptor.SetTarget(target);
            return(mock);
        }