public void GetServicesFrom_NotDecoratedWithServiceAttribute_NoServicesReturned() { ServiceRegistrationBehavior behavior = new ServiceRegistrationBehavior(); IEnumerable <ServiceInfo> services = behavior.GetServicesFrom(typeof(MyNonService)); Assert.Empty(services); }
public void GetServicesFrom_DecoratedWithAttribute_ServiceInfoWithAttributeParameters() { ServiceRegistrationBehavior behavior = new ServiceRegistrationBehavior(); IEnumerable <ServiceInfo> services = behavior.GetServicesFrom(typeof(MyService)); ServiceInfo expected = new ServiceInfo(typeof(IMyService), typeof(MyService), "SomeContractName", Lifetime.Application); AssertEx.AreEquivalent(services, ServiceInfoEquals, expected); }
public void GetServicesFrom_ServiceAttributeDoesNotHaveExportType_DecoratedTypeUsedAsFromType() { ServiceAttribute service = new ServiceAttribute(); Type fakeType = GetFakeType(service); ServiceRegistrationBehavior behavior = GetTarget(); IEnumerable <ServiceInfo> services = behavior.GetServicesFrom(fakeType); ServiceInfo[] expected = { new ServiceInfo(fakeType, fakeType, Lifetime.Instance) }; AssertEx.AreEquivalent(services, ServiceInfoEquals, expected); }
public void GetServicesFrom_DecoratedWithTwoAttributes_TwoServiceInfoReturned() { ServiceInfo expected1 = new ServiceInfo(typeof(IMyService), typeof(MyDoubleService), "SomeContractName", Lifetime.Application); ServiceInfo expected2 = new ServiceInfo(typeof(IMyService), typeof(MyDoubleService), "SomeOtherContractName", Lifetime.Instance); ServiceRegistrationBehavior behavior = new ServiceRegistrationBehavior(); IEnumerable <ServiceInfo> services = behavior.GetServicesFrom(typeof(MyDoubleService)); AssertEx.AreEquivalent(services, ServiceInfoEquals, expected1, expected2); }