当前位置: 首页>>代码示例>>C#>>正文


C# Mock.Select方法代码示例

本文整理汇总了C#中Mock.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.Select方法的具体用法?C# Mock.Select怎么用?C# Mock.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mock的用法示例。


在下文中一共展示了Mock.Select方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateWebHookFilterManager

 internal static IWebHookFilterManager CreateWebHookFilterManager(int providerCount)
 {
     Mock<IWebHookFilterProvider>[] providerMocks = new Mock<IWebHookFilterProvider>[providerCount];
     for (int cnt = 0; cnt < providerMocks.Length; cnt++)
     {
         providerMocks[cnt] = CreateFilterProvider(cnt);
     }
     WebHookFilterManager manager = new WebHookFilterManager(providerMocks.Select(p => p.Object));
     return manager;
 }
开发者ID:itomek,项目名称:WebHooks,代码行数:10,代码来源:WebHookFilterManagerTests.cs

示例2: ThrowWhenNullIndexOutOfBounds

        internal void ThrowWhenNullIndexOutOfBounds(
            Mock<ParameterInfo>[] parameterMocks,
            SpecimenProvider sut)
        {
            // Arrange
            List<ParameterInfo> parameters = parameterMocks.Select(pm => pm.Object).ToList();

            // Act/Assert
            string actualParamName =
                Assert.Throws<ArgumentException>(
                    () => ((ISpecimenProvider)sut).GetParameterSpecimens(parameters, parameters.Count))
                      .ParamName;
            Assert.Equal("nullIndex", actualParamName);
        }
开发者ID:AutoTestNET,项目名称:AutoTest.ArgumentNullException,代码行数:14,代码来源:SpecimenProviderShould.cs

示例3: CreateControllerWillReturnFirstControllerResultFromFactories

        public void CreateControllerWillReturnFirstControllerResultFromFactories(
            string controllerName, 
            RequestContext requestContext,
            IController expectedResult,
            Mock<IControllerFactory>[] factoryStubs)
        {
            // Fixture Setup
            factoryStubs[0]
                .Setup(x => x.CreateController(requestContext, controllerName))
                .Returns((IController)null);
            factoryStubs[1]
                .Setup(x => x.CreateController(requestContext, controllerName))
                .Returns(expectedResult);
            factoryStubs[2]
                .Setup(x => x.CreateController(requestContext, controllerName))
                .Returns((IController)null);

            var sut = new CompositeControllerFactory(factoryStubs.Select(x => x.Object));
            // Exercise system
            var result = sut.CreateController(requestContext, controllerName);
            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
开发者ID:moodmosaic-attic,项目名称:System.Web.Mvc.Composition,代码行数:24,代码来源:CompositeControllerFactoryFacts.cs

示例4: CreateTargetsFromParameters

 protected override ITarget[] CreateTargetsFromParameters(MethodInfo method)
 {
     TargetMocks = method.GetParameters().Select(p => new Mock<ITarget>()).ToArray();
     return TargetMocks.Select(m => m.Object).ToArray();
 }
开发者ID:bbawol,项目名称:ninject,代码行数:5,代码来源:MethodInjectionStrategyTests.cs

示例5: DefaultHttpControllerTypeResolverTracerTest

        public DefaultHttpControllerTypeResolverTracerTest()
        {
            ExpectedTypes = new List<Type>
            {
                typeof(ValidController), typeof(UsersRpcController), typeof(UsersController),
            };

            Type[] fine1Types = new Type[]
            {
                typeof(DefaultHttpControllerTypeResolverTracerTest),
                null,
                typeof(ValidController),
            };
            Type[] poorTypes = new Type[]
            {
                typeof(string),
                null,
                typeof(Action),
                null,
                typeof(UsersRpcController),
            };
            Type[] fine2Types = new Type[]
            {
                typeof(DefaultHttpControllerTypeResolver),
                null,
                typeof(DefaultHttpControllerTypeResolverTracer),
                null,
                typeof(UsersController)
            };

            Exception worseException = new Exception(ExceptionMessage);
            Exception poorException = new ReflectionTypeLoadException(poorTypes, new Exception[] { worseException });
            ExpectedTraces = new List<TraceRecord>
            {
                new TraceRecord(null, TraceCategories.ControllersCategory, TraceLevel.Debug)
                {
                    Kind = TraceKind.Begin,
                    Operator = "DefaultHttpControllerTypeResolverProxy", // Moq type name
                    Operation = "GetControllerTypes",
                },
                new TraceRecord(null, TraceCategories.ControllersCategory, TraceLevel.Warn)
                {
                    Kind = TraceKind.Trace,
                    Exception = poorException,
                    Message = "Exception thrown while getting types from 'PoorAssembly'.",
                },
                new TraceRecord(null, TraceCategories.ControllersCategory, TraceLevel.Warn)
                {
                    Kind = TraceKind.Trace,
                    Exception = worseException,
                    Message = "Exception thrown while getting types from 'WorseAssembly'.",
                },
                new TraceRecord(null, TraceCategories.ControllersCategory, TraceLevel.Debug)
                {
                    Kind = TraceKind.End,
                    Operator = "DefaultHttpControllerTypeResolverProxy",
                    Operation = "GetControllerTypes",
                },
            };

            Mock<MockableAssembly> fine1Assembly = new Mock<MockableAssembly>(MockBehavior.Strict);
            fine1Assembly.Setup(assembly => assembly.GetTypes()).Returns(fine1Types);
            fine1Assembly.SetupGet(assembly => assembly.IsDynamic).Returns(false);

            Exception[] exceptions = new Exception[] { new Exception(ExceptionMessage), };
            Mock<MockableAssembly> poorAssembly = new Mock<MockableAssembly>(MockBehavior.Strict);
            poorAssembly.Setup(assembly => assembly.GetTypes()).Throws(poorException);
            poorAssembly.SetupGet(assembly => assembly.IsDynamic).Returns(false);
            poorAssembly.SetupGet(assembly => assembly.FullName).Returns("PoorAssembly");

            Mock<MockableAssembly> worseAssembly = new Mock<MockableAssembly>(MockBehavior.Strict);
            worseAssembly.Setup(assembly => assembly.GetTypes()).Throws(worseException);
            worseAssembly.SetupGet(assembly => assembly.IsDynamic).Returns(false);
            worseAssembly.SetupGet(assembly => assembly.FullName).Returns("WorseAssembly");

            Mock<MockableAssembly> fine2Assembly = new Mock<MockableAssembly>(MockBehavior.Strict);
            fine2Assembly.Setup(assembly => assembly.GetTypes()).Returns(fine2Types);
            fine2Assembly.SetupGet(assembly => assembly.IsDynamic).Returns(false);

            Mock<MockableAssembly> dynamicAssembly = new Mock<MockableAssembly>(MockBehavior.Strict);
            dynamicAssembly.SetupGet(assembly => assembly.IsDynamic).Returns(true);

            Assemblies = new Mock<MockableAssembly>[]
            {
                fine1Assembly,
                poorAssembly,
                worseAssembly,
                fine2Assembly,
                dynamicAssembly,
            };

            AssembliesResolver = new Mock<IAssembliesResolver>(MockBehavior.Strict);
            AssembliesResolver.Setup(resolver => resolver.GetAssemblies()).Returns(
                Assemblies.Select(assembly => (Assembly)assembly.Object).AsCollection());

            HttpControllerTypeResolver =
                new Mock<DefaultHttpControllerTypeResolver>() { CallBase = true, };
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:98,代码来源:DefaultHttpControllerTypeResolverTracerTest.cs

示例6: InitMocks

        private void InitMocks(int numArrayElements)
        {
            mockBindingsFactory = new Mock<IBindingsFactory>();

            testArray = Enumerable.Range(0, numArrayElements)
                .Select(i => new TestClass())
                .ToArray();

            mockArrayItemBindings = Enumerable.Range(0, numArrayElements)
                .Select(i =>
                {
                    var mockBinding = new Mock<IArrayItemBinding>();

                    mockBinding
                        .Setup(m => m.ItemIndex)
                        .Returns(i);

                    return mockBinding;
                })
                .ToArray();

            mockBindingsFactory
               .Setup(m => m.CreateArrayBindings(testArray))
               .Returns(mockArrayItemBindings.Select(m => m.Object).ToArray());
        }
开发者ID:ashleydavis,项目名称:Binding-System,代码行数:25,代码来源:ArrayBindingTests.cs

示例7: SetupGetAllDevices

 public void SetupGetAllDevices(Mock<ITelldusDevice>[] telldusDevices)
 {
     TelldusCoreMock.Setup(m => m.GetAllDevices()).Returns(telldusDevices.Select(d => d.Object).ToArray());
 }
开发者ID:johanclasson,项目名称:Akkomation,代码行数:4,代码来源:TelldusCoreMockFixture.cs


注:本文中的Mock.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。