public void GetService_CallsTheConstructorThatIsAttributed_WhenThereIsMoreThanOneConstructorAndOnlyOneIsAttributed() { IServiceProvider provider = new FactoryServiceProvider<TwoConstructorsAttributes>(); IA ia = NewStub<IA>(); IB ib = NewStub<IB>(); SetupResult.For(context.HasService(typeof (IA))).Return(true); SetupResult.For(context.GetService(typeof (IA))).Return(ia); SetupResult.For(context.HasService(typeof (IB))).Return(true); SetupResult.For(context.GetService(typeof (IB))).Return(ib); SetupComplete(); IC service = (IC) provider.GetService(typeof (IC), typeof (IC), context); Assert.AreEqual(ia, service.A); Assert.AreEqual(ib, service.B); }
public void GetService_ThrowsException_WhenThereAreMultipleConstructorsThatAreAttributed() { IServiceProvider provider = new FactoryServiceProvider<TwoConstructorsTwoAttributes>(); SetupComplete(); provider.GetService(typeof (IC), typeof (IC), context); }
public void GetService_ThrowsException_WhenThereAreMultipleConstructorsButNoneAreAttributed() { IServiceProvider provider = new FactoryServiceProvider<TwoConstructorsNoAttributes>(); IA ia = NewStub<IA>(); IB ib = NewStub<IB>(); SetupResult.For(context.HasService(typeof (IA))).Return(true); SetupResult.For(context.GetService(typeof (IA))).Return(ia); SetupResult.For(context.HasService(typeof (IB))).Return(true); SetupResult.For(context.GetService(typeof (IB))).Return(ib); SetupComplete(); provider.GetService(typeof (IC), typeof (IC), context); }