本文整理汇总了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);
}
示例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);
}
示例3: Customize
public void Customize(IFixture fixture)
{
var config = fixture.CreateAnonymous<HttpConfiguration>();
fixture.Customize<HttpRequestMessage>(c => c
.Do(x =>
{
x.Properties[HttpPropertyKeys.HttpConfigurationKey] =
config;
}));
}
示例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());
}
示例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>()
});
}
示例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>()
});
}
示例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);
}
示例8: Customize
public void Customize(IFixture fixture)
{
fixture.Register(() => fixture.CreateAnonymous<Mock<Stream>>().Object);
}
示例9: Setup
public void Setup()
{
_fixture = new Fixture().Customize(new AutoMoqCustomization());
_sut = _fixture.CreateAnonymous<Configure>();//.WithVersion_For_Tests();
_container = _fixture.Freeze<Mock<IContainer>>();
}
示例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());
}