本文整理汇总了C#中Fakes.FakeTypeFinder类的典型用法代码示例。如果您正苦于以下问题:C# Fakes.FakeTypeFinder类的具体用法?C# Fakes.FakeTypeFinder怎么用?C# Fakes.FakeTypeFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Fakes.FakeTypeFinder类属于命名空间,在下文中一共展示了Fakes.FakeTypeFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanResolve_MultipleServices
public void CanResolve_MultipleServices()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(HighService), typeof(LowService));
ServiceRegistrator registrator = new ServiceRegistrator(finder, container);
registrator.RegisterServices(registrator.FindServices());
var services = container.ResolveAll<IBarometer>();
Assert.That(services.Count(), Is.EqualTo(2));
}
示例2: Plugin_WithoutInitializerDefinition_IsNotInvoked
public void Plugin_WithoutInitializerDefinition_IsNotInvoked()
{
ITypeFinder typeFinder = new Fakes.FakeTypeFinder(new[] { typeof(PlugIn3) });
PluginBootstrapper invoker = new PluginBootstrapper(typeFinder);
invoker.InitializePlugins(null, invoker.GetPluginDefinitions());
Assert.That(PlugIn3.WasInitialized, Is.False);
}
示例3: AutoInitializePlugin_IsInvoked
public void AutoInitializePlugin_IsInvoked()
{
ITypeFinder typeFinder = new Fakes.FakeTypeFinder(new[] { typeof(PlugIn2) });
PluginBootstrapper invoker = new PluginBootstrapper(typeFinder);
PlugIn2.WasInitialized = false;
invoker.InitializePlugins(null, invoker.GetPluginDefinitions());
Assert.That(PlugIn2.WasInitialized, Is.True);
}
示例4: GenericServices_CanBeResolved
public void GenericServices_CanBeResolved()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(GenericSelfService<>));
DependencyAttributeRegistrator registrator = new DependencyAttributeRegistrator(finder, engine);
registrator.RegisterServices(registrator.FindServices());
Assert.That(engine.Resolve<GenericSelfService<int>>(), Is.InstanceOf<GenericSelfService<int>>());
Assert.That(engine.Resolve<GenericSelfService<string>>(), Is.InstanceOf<GenericSelfService<string>>());
}
示例5: CanDependOn_MultipleServices
public void CanDependOn_MultipleServices()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(HighService), typeof(LowService));
ServiceRegistrator registrator = new ServiceRegistrator(finder, container);
registrator.RegisterServices(registrator.FindServices());
container.AddComponent("bw", typeof(BarometerWatcher), typeof(BarometerWatcher));
var watcher = container.Resolve<BarometerWatcher>();
Assert.That(watcher.Barometers.Count(), Is.EqualTo(2));
}
示例6: GenericServices_CanBeResolved_ByServiceInterface
public void GenericServices_CanBeResolved_ByServiceInterface()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(GenericInterfacedService<>));
ServiceRegistrator registrator = new ServiceRegistrator(finder, container);
registrator.RegisterServices(registrator.FindServices());
Assert.That(container.Resolve<IGenericService<int>>(), Is.InstanceOf<GenericInterfacedService<int>>());
Assert.That(container.Resolve<IGenericService<string>>(), Is.InstanceOf<GenericInterfacedService<string>>());
}
示例7: Services_AreAdded_ToTheContainer
public void Services_AreAdded_ToTheContainer()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(SelfService), typeof(NonAttributed));
ServiceRegistrator registrator = new ServiceRegistrator(finder, container);
registrator.RegisterServices(registrator.FindServices());
Assert.That(container.Resolve<SelfService>(), Is.InstanceOf<SelfService>());
Assert.That(new TestDelegate(() => container.Resolve<NonAttributed>()), Throws.Exception);
}
示例8: GenericServices_CanDepend_OnEachOther
public void GenericServices_CanDepend_OnEachOther()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(GenericSelfService<>), typeof(GenericDependingService));
DependencyAttributeRegistrator registrator = new DependencyAttributeRegistrator(finder, engine);
registrator.RegisterServices(registrator.FindServices());
var service = engine.Resolve<GenericDependingService>();
Assert.That(service, Is.InstanceOf<GenericDependingService>());
Assert.That(service.service, Is.InstanceOf<GenericSelfService<int>>());
}
示例9: Services_CanDepend_OnEachOther
public void Services_CanDepend_OnEachOther()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(SelfService), typeof(DependingService));
ServiceRegistrator registrator = new ServiceRegistrator(finder, container);
registrator.RegisterServices(registrator.FindServices());
var service = container.Resolve<DependingService>();
Assert.That(service, Is.InstanceOf<DependingService>());
Assert.That(service.service, Is.InstanceOf<SelfService>());
}
示例10: CanResolve_ServiceWithDependency_OnComponentInstance
public void CanResolve_ServiceWithDependency_OnComponentInstance()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(DependingServiceWithMissingDependency).Assembly.GetTypes());
ServiceRegistrator registrator = new ServiceRegistrator(finder, container);
registrator.RegisterServices(registrator.FindServices());
container.AddComponentInstance("ud", typeof(UnregisteredDependency), new UnregisteredDependency());
var service = container.Resolve<DependingServiceWithMissingDependency>();
Assert.That(service, Is.InstanceOf<DependingServiceWithMissingDependency>());
}
示例11: Services_AreAdded_ToTheContainer_WithServiceType
public void Services_AreAdded_ToTheContainer_WithServiceType()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(InterfacedService), typeof(NonAttributed));
DependencyAttributeRegistrator registrator = new DependencyAttributeRegistrator(finder, engine);
registrator.RegisterServices(registrator.FindServices());
Assert.That(engine.Resolve<IService>(), Is.Not.Null);
Assert.That(engine.Resolve<IService>(), Is.InstanceOf<InterfacedService>());
Assert.That(new TestDelegate(() => engine.Resolve<NonAttributed>()), Throws.Exception);
}
示例12: CanResolve_ServiceWithDependency_OnComponentInstance
public void CanResolve_ServiceWithDependency_OnComponentInstance()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(DependingServiceWithMissingDependency).Assembly.GetTypes());
DependencyAttributeRegistrator registrator = new DependencyAttributeRegistrator(finder, engine);
registrator.RegisterServices(registrator.FindServices());
engine.ContainerManager.AddComponentInstance<UnregisteredDependency>(new UnregisteredDependency(), "ud");
var service = engine.Resolve<DependingServiceWithMissingDependency>();
Assert.That(service, Is.InstanceOf<DependingServiceWithMissingDependency>());
}
示例13: Services_AreSingletons
public void Services_AreSingletons()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(SelfService));
ServiceRegistrator registrator = new ServiceRegistrator(finder, container);
registrator.RegisterServices(registrator.FindServices());
var one = container.Resolve<SelfService>();
var two = container.Resolve<SelfService>();
Assert.That(object.ReferenceEquals(one, two));
}
示例14: Services_AreSingletons
public void Services_AreSingletons()
{
ITypeFinder finder = new Fakes.FakeTypeFinder(typeof(SelfService));
DependencyAttributeRegistrator registrator = new DependencyAttributeRegistrator(finder, engine);
registrator.RegisterServices(registrator.FindServices());
var one = engine.Resolve<SelfService>();
var two = engine.Resolve<SelfService>();
Assert.That(object.ReferenceEquals(one, two));
}
示例15: AutoInitialized_PluginInitializers_CanBeRemoved_UsingConfiguration_ByType
public void AutoInitialized_PluginInitializers_CanBeRemoved_UsingConfiguration_ByType()
{
ITypeFinder typeFinder = new Fakes.FakeTypeFinder(typeof(PlugIn1).Assembly, new[] { typeof(PlugIn2) });
EngineSection config = CreateConfiguration(null, new[]
{
new PluginInitializerElement { Name = "ignored", Type = typeof(PlugIn2).AssemblyQualifiedName }
});
PluginBootstrapper invoker = new PluginBootstrapper(typeFinder, config);
invoker.InitializePlugins(null, invoker.GetPluginDefinitions());
Assert.That(PlugIn2.WasInitialized, Is.False);
}