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


C# IFixture.CreateAnonymous方法代码示例

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


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

示例1: Customize

 public void Customize(IFixture fixture)
 {
     fixture.Customize<VoIPTransport>(x => x.FromFactory<ITransportApiProvider>(t => new UdpTransport(t)));
     fixture.Customize<Account>(x => x.OmitAutoProperties());
     var account = fixture.Freeze<Mock<Account>>();
     account.SetupGet(x => x.Id).Returns(fixture.CreateAnonymous<int>());
     account.SetupGet(x => x.Transport).Returns(fixture.CreateAnonymous<IVoIPTransport>());
     fixture.Register(() => account.Object);
 }
开发者ID:sanjeevspr,项目名称:pjsip4net,代码行数:9,代码来源:AccountCustomization.cs

示例2: Customize

            public void Customize(IFixture fixture)
            {
                var requestMock = fixture.CreateAnonymous<Mock<HttpRequestBase>>();
                var responseMock = fixture.CreateAnonymous<Mock<HttpResponseBase>>();
                var userMock = fixture.CreateAnonymous<Mock<IPrincipal>>();
                var mock = new Mock<HttpContextBase>(MockBehavior.Loose);
                mock.Setup(m => m.Request).Returns(requestMock.Object);
                mock.Setup(m => m.Response).Returns(responseMock.Object);
                mock.Setup(m => m.User).Returns(userMock.Object);

                fixture.Inject(mock);
            }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:12,代码来源:HttpMocksCustomization.cs

示例3: Customize

            public void Customize(IFixture fixture)
            {
                var config = fixture.CreateAnonymous<HttpConfiguration>();

                fixture.Customize<HttpRequestMessage>(c => c
                    .Do(x =>
                    {
                        x.Properties[HttpPropertyKeys.HttpConfigurationKey] =
                            config;
                    }));
            }
开发者ID:olcayseker,项目名称:Hyprlinkr,代码行数:11,代码来源:HyprlinkrCustomization.cs

示例4: Customize

        public void Customize(IFixture fixture)
        {
            fixture.Customize<ViewDataDictionary>(c =>
                c.Without(vdd => vdd.ModelMetadata));

            fixture.Customize<HttpContextBase>(ob => ob
                .FromFactory(() =>
                {
                    var contextStub = new Mock<HttpContextBase>();
                    contextStub.SetupProperty(ctx => ctx.User);
                    contextStub.Object.User = fixture.CreateAnonymous<IPrincipal>();
                    return contextStub.Object;
                })
                .OmitAutoProperties());
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:15,代码来源:MvcCustomization.cs

示例5: ActionExecutingContext

 private static void ActionExecutingContext(IFixture fixture)
 {
     fixture.Register<ControllerContext, ActionDescriptor, ActionExecutingContext>(
         (controllerContext, actionDescriptor) => new ActionExecutingContext(
                                                      controllerContext,
                                                      actionDescriptor,
                                                      fixture.CreateAnonymous<IDictionary<string, object>>())
                                                      {
                                                          Result = fixture.CreateAnonymous<ActionResult>()
                                                      });
 }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:11,代码来源:MvcCustomizations.cs

示例6: ActionExecutedContext

 private static void ActionExecutedContext(IFixture fixture)
 {
     fixture.Register<ControllerContext, ActionDescriptor, bool, Exception, ActionExecutedContext>(
         (controllerContext, actionDescriptor, canceled, exception) =>
         new ActionExecutedContext(controllerContext, actionDescriptor, canceled, exception)
             {
                 Result = fixture.CreateAnonymous<ActionResult>()
             });
 }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:9,代码来源:MvcCustomizations.cs

示例7: Customize

        /// <summary>
        /// Customizes the fixture by freezing the value of <see cref="TargetType"/>.
        /// </summary>
        /// <param name="fixture">The fixture to customize.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="fixture"/> is null.
        /// </exception>
        public void Customize(IFixture fixture)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException("fixture");
            }

            var specimen = fixture.CreateAnonymous(
                    this.targetType);
            var fixedBuilder = new FixedBuilder(specimen);

            var types = new[]
                {
                    this.targetType,
                    this.registeredType 
                };

            var builder = new CompositeSpecimenBuilder(
                from t in types
                select new TypedBuilderComposer(
                    t, fixedBuilder).Compose());

            fixture.Customizations.Insert(0, builder);
        }
开发者ID:rajeshgupthar,项目名称:AutoFixture,代码行数:31,代码来源:FreezingCustomization.cs

示例8: Customize

 public void Customize(IFixture fixture)
 {
     fixture.Register(() => fixture.CreateAnonymous<Mock<Stream>>().Object);
 }
开发者ID:Winsto,项目名称:Booking,代码行数:4,代码来源:PersistenceCustomization.cs

示例9: Setup

 public void Setup()
 {
     _fixture = new Fixture().Customize(new AutoMoqCustomization());
     _sut = _fixture.CreateAnonymous<Configure>();//.WithVersion_For_Tests();
     _container = _fixture.Freeze<Mock<IContainer>>();
 }
开发者ID:kumarkmmca,项目名称:pjsip4net,代码行数:6,代码来源:given_a_configure.cs

示例10: Customize

            public void Customize(IFixture fixture)
            {
                fixture.Customize<Mock<MethodInfo>>(c => c
                    .Do(stub => stub
                        .SetupGet(m => m.ReflectedType.Name)
                        .Returns(fixture.CreateAnonymous<string>())));

                Expression<Action<FooController>> exp = c => c.GetDefault();
                fixture.Inject(exp.GetBodyMethodCallExpression());
            }
开发者ID:JoachimL,项目名称:Hyprlinkr,代码行数:10,代码来源:HyprlinkrCustomization.cs


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