本文整理汇总了C#中Castle.MicroKernel.DefaultKernel.CreateComponentActivator方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultKernel.CreateComponentActivator方法的具体用法?C# DefaultKernel.CreateComponentActivator怎么用?C# DefaultKernel.CreateComponentActivator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.MicroKernel.DefaultKernel
的用法示例。
在下文中一共展示了DefaultKernel.CreateComponentActivator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LeaseIsCorrectWhenAccessedAfterInitializationButNoLeaseIsAvailableInKernel
public void LeaseIsCorrectWhenAccessedAfterInitializationButNoLeaseIsAvailableInKernel()
{
// Fixture setup
var kernel = new DefaultKernel();
var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
var activator = kernel.CreateComponentActivator(model);
var sut = new CacheLifestyleManager();
sut.Init(activator, kernel, model);
// Exercise system
var result = sut.Lease;
// Verify outcome
var actual = Assert.IsAssignableFrom<SlidingLease>(result);
Assert.Equal(TimeSpan.FromMinutes(1), actual.Timeout);
// Teardown
}
示例2: LeaseIsCorrectWhenAccessedAfterInitializationWhenLeaseIsAvailabeInKernel
public void LeaseIsCorrectWhenAccessedAfterInitializationWhenLeaseIsAvailabeInKernel()
{
// Fixture setup
var kernel = new DefaultKernel();
var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
var activator = kernel.CreateComponentActivator(model);
var expectedLease = new Mock<ILease> { DefaultValue = DefaultValue.Mock }.Object;
kernel.Register(Component.For<ILease>().Instance(expectedLease));
var sut = new CacheLifestyleManager();
sut.Init(activator, kernel, model);
// Exercise system
var result = sut.Lease;
// Verify outcome
Assert.Equal(expectedLease, result);
// Teardown
}
示例3: ResolveOnceReturnsCorrectResult
public void ResolveOnceReturnsCorrectResult()
{
// Fixture setup
var kernel = new DefaultKernel();
var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
var activator = kernel.CreateComponentActivator(model);
var sut = new CacheLifestyleManager();
sut.Init(activator, kernel, model);
// Exercise system
var result = sut.Resolve(CreationContext.Empty);
// Verify outcome
Assert.IsAssignableFrom<Version>(result);
// Teardown
}
示例4: ReleaseWrongObjectWillNotReleaseInstance
public void ReleaseWrongObjectWillNotReleaseInstance()
{
// Fixture setup
var kernel = new DefaultKernel();
var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
var activator = kernel.CreateComponentActivator(model);
var leaseMock = new Mock<ILease> { DefaultValue = DefaultValue.Mock };
kernel.Register(Component.For<ILease>().Instance(leaseMock.Object));
var sut = new CacheLifestyleManager();
sut.Init(activator, kernel, model);
var first = sut.Resolve(CreationContext.Empty);
// Exercise system
sut.Release(new object());
// Verify outcome
var second = sut.Resolve(CreationContext.Empty);
Assert.Same(first, second);
// Teardown
}
示例5: ResolveWillReturnNewInstanceWhenLeaseExpires
public void ResolveWillReturnNewInstanceWhenLeaseExpires()
{
// Fixture setup
var kernel = new DefaultKernel();
var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
var activator = kernel.CreateComponentActivator(model);
var expired = false;
var leaseStub = new Mock<ILease> { DefaultValue = DefaultValue.Mock };
leaseStub.Setup(l => l.IsExpired).Returns(() =>
{
var b = expired;
expired = !expired;
return b;
});
kernel.Register(Component.For<ILease>().Instance(leaseStub.Object));
var sut = new CacheLifestyleManager();
sut.Init(activator, kernel, model);
// Exercise system
var first = sut.Resolve(CreationContext.Empty);
var second = sut.Resolve(CreationContext.Empty);
// Verify outcome
Assert.NotSame(first, second);
// Teardown
}
示例6: MultipleResolvesWillOnlyRenewOnce
public void MultipleResolvesWillOnlyRenewOnce()
{
// Fixture setup
var kernel = new DefaultKernel();
var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
var activator = kernel.CreateComponentActivator(model);
var leaseMock = new Mock<ILease> { DefaultValue = DefaultValue.Mock };
kernel.Register(Component.For<ILease>().Instance(leaseMock.Object));
var sut = new CacheLifestyleManager();
sut.Init(activator, kernel, model);
// Exercise system
sut.Resolve(CreationContext.Empty);
sut.Resolve(CreationContext.Empty);
// Verify outcome
leaseMock.Verify(l => l.Renew(), Times.Once());
// Teardown
}
示例7: ResolveTwiceReturnsSame
public void ResolveTwiceReturnsSame()
{
// Fixture setup
var kernel = new DefaultKernel();
var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
var activator = kernel.CreateComponentActivator(model);
var sut = new CacheLifestyleManager();
sut.Init(activator, kernel, model);
// Exercise system
var first = sut.Resolve(CreationContext.Empty);
var second = sut.Resolve(CreationContext.Empty);
// Verify outcome
Assert.Same(first, second);
// Teardown
}