本文整理汇总了C#中IFixture.Inject方法的典型用法代码示例。如果您正苦于以下问题:C# IFixture.Inject方法的具体用法?C# IFixture.Inject怎么用?C# IFixture.Inject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFixture
的用法示例。
在下文中一共展示了IFixture.Inject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NullForCtorArgumentsThrowsException
public void NullForCtorArgumentsThrowsException(IFixture fixture, Name name)
{
fixture.Inject<IParameter>(new ParameterTest());
fixture.Inject<ParameterMeta>(ParameterMeta.Create<IParameter>(name));
var assertion = new GuardClauseAssertion(fixture);
assertion.Verify(typeof(CmdApplicationConfiguration).GetConstructors());
}
示例2: CtorParametersAreInitialized
public void CtorParametersAreInitialized(IFixture fixture, Name name)
{
fixture.Inject<IParameter>(new ParameterTest());
fixture.Inject<ParameterMeta>(ParameterMeta.Create<IParameter>(name));
var assertion = new ConstructorInitializedMemberAssertion(fixture);
assertion.Verify(typeof(CmdApplicationConfiguration));
}
示例3: MessageProcessingAsyncWrapper
public MessageProcessingAsyncWrapper()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
ReceiveMessages = _fixture.Create<IReceiveMessagesFactory>();
MessageContextFactory = _fixture.Create<IMessageContextFactory>();
_fixture.Inject(ReceiveMessages);
_fixture.Inject(MessageContextFactory);
}
示例4: Customize
public void Customize(IFixture fixture)
{
var database = Database.GetDatabase("master");
fixture.Inject(database);
fixture.Inject(Substitute.For<DataStorage>(database));
fixture.Register(ItemHelper.CreateInstance);
fixture.Register(() => Language.Parse("en"));
}
示例5: Customize
public void Customize(IFixture fixture)
{
fixture.Inject<Func<bool>>(() => false);
fixture.Inject<Func<object, bool>>(x => false);
fixture.Inject<Func<string, bool>>(x => false);
fixture.Inject<Func<int, bool>>(x => false);
fixture.Inject<Func<Version, bool>>(x => false);
}
示例6: MessageProcessingWrapper
public MessageProcessingWrapper()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
ReceiveMessages = _fixture.Create<IReceiveMessages>();
var factory = _fixture.Create<IReceiveMessagesFactory>();
factory.Create().ReturnsForAnyArgs(ReceiveMessages);
_fixture.Inject(factory);
MessageContextFactory = _fixture.Create<IMessageContextFactory>();
_fixture.Inject(ReceiveMessages);
_fixture.Inject(MessageContextFactory);
}
示例7: CreateMainViewModel
private MainViewModel CreateMainViewModel(IFixture fixture, IMessenger messenger = null)
{
var channel = fixture.Create<IChannel<SaveCmdApplicationConfigurationCommand>>();
fixture.Register<ICmdApplicationConfigurationViewModelFactory>(() => fixture.Create<CmdApplicationConfigurationViewModelFactory>());
fixture.Inject(messenger ?? new Messenger());
return fixture.Build<MainViewModel>().OmitAutoProperties().Create();
}
示例8: Customize
public void Customize(IFixture fixture)
{
fixture.Customize<ModelBindingContext>(c => c
.Without(x => x.Model)
.Without(x => x.ModelType));
fixture.Inject(CultureInfo.CurrentCulture);
}
示例9: ConstructWithNullLoggerThrows
public void ConstructWithNullLoggerThrows(
IFixture fixture)
{
fixture.Inject<ILogger>(null);
var e = Assert.Throws<TargetInvocationException>(() => fixture.Create<NotifyErrorAttribute>());
Assert.IsType<ArgumentNullException>(e.InnerException);
}
示例10: Customize
public void Customize(IFixture fixture)
{
var mock = new Mock<HttpRequestBase>(MockBehavior.Strict);
mock.Setup(r => r.UserHostAddress).Returns("127.0.0.1");
fixture.Inject(mock);
}
示例11: PropertiesAreCorrectlyInitialized
public void PropertiesAreCorrectlyInitialized(IFixture fixture, ConstructorInitializedMemberAssertion assertion)
{
// Fixture setup
fixture.Inject(JSendStatus.Error);
var properties = typeof (JSendError).GetProperties();
// Exercise system and verify outcome
assertion.Verify(properties);
}
示例12: Customize
public void Customize(IFixture fixture)
{
var urlFactoryMock = new Mock<UrlHelper>();
urlFactoryMock.Setup(x => x.Link(It.IsAny<string>(), It.IsAny<IDictionary<string, object>>()))
.Returns((string name, IDictionary<string, object> values) => RouteLink);
fixture.Inject(urlFactoryMock.Object);
}
示例13: Customize
public void Customize(IFixture fixture)
{
foreach (var customization in fixture.Customizations.Where(c => c is NodeComposer<Db>))
{
fixture.Customizations.Remove(customization);
}
fixture.Inject(new Db("core"));
}
示例14: GetApplicationConfigurationMeta
private CmdApplicationMeta GetApplicationConfigurationMeta(string applicationName, string friendlyName, IFixture fixture)
{
// TODO: This can be generalized
fixture.Inject<Type>(typeof(IParameter));
return fixture.Build<CmdApplicationMeta>()
.FromSeed(a => new CmdApplicationMeta(
(Name)friendlyName,
(Name)applicationName,
new List<ParameterMeta>()))
.Create();
}
示例15: Setup
public void Setup()
{
_autofixture = new Fixture();
new TalesModelCustomisation().Customize(_autofixture);
_pathEvaluator = new Mock<IExpressionEvaluator>();
var registry = new Mock<IEvaluatorSelector>();
_autofixture.Inject(registry.Object);
_model = _autofixture.Create<TalesModel>();
registry.Setup(x => x.GetEvaluator<PathExpressionEvaluator>()).Returns(_pathEvaluator.Object);
_sut = new StringExpressionEvaluator(registry.Object);
}