Пример #1
0
        public Mock(MockBehavior behavior, params object[] args)
        {
            if (args == null)
            {
                args = new object[] { null };
            }

            this.additionalInterfaces    = new List <Type>();
            this.behavior                = behavior;
            this.configuredDefaultValues = new Dictionary <Type, object>();
            this.constructorArguments    = args;
            this.defaultValueProvider    = DefaultValueProvider.Empty;
            this.eventHandlers           = new EventHandlerCollection();
            this.innerMocks              = new ConcurrentDictionary <MethodInfo, MockWithWrappedMockObject>();
            this.invocations             = new InvocationCollection();
            this.name     = CreateUniqueDefaultMockName();
            this.setups   = new SetupCollection();
            this.switches = Switches.Default;

            this.CheckParameters();
        }
Пример #2
0
 public static Mock FindLastInnerMock(this SetupCollection setups, Func <Setup, bool> predicate)
 {
     return(setups.FindLast(setup => !setup.IsConditional && predicate(setup))?.InnerMocks.SingleOrDefault());
 }
Пример #3
0
 public static IEnumerable <Mock> FindAllInnerMocks(this SetupCollection setups)
 {
     return(setups.FindAll(setup => !setup.IsConditional)
            .SelectMany(setup => setup.InnerMocks)
            .Where(innerMock => innerMock != null));
 }