public void GetServicesFrom_ExportInterfacesNoInterfaces_NothingRegistered() { ServiceBuilder builder = new ServiceBuilder(t => t == typeof(MyOtherService)); builder.ExportInterfaces(); ServiceInfo[] service = builder.GetServicesFrom(typeof(MyOtherService)).ToArray(); Assert.Equal(0, service.Length); }
public void GetServicesFrom_ExportInterfacesWithFilter_RegisterContractType() { ServiceBuilder builder = new ServiceBuilder(t => t == typeof(MyService)); builder.ExportInterfaces(x => x == typeof(IMyService2)); List <ServiceInfo> services = builder.GetServicesFrom(typeof(MyService)).ToList(); ServiceInfo expected = new ServiceInfo(typeof(IMyService2), typeof(MyService), Lifetime.Instance); AssertEx.AreEquivalent(services, this.comparer.Equals, expected); }
public void GetServicesFrom_ExportInterfacesMultipleInterfacesWithExportConfig_RegisterConfig() { ServiceBuilder builder = new ServiceBuilder(t => t == typeof(MyService)); builder.ExportInterfaces(c => true, b => b.WithLifetime(Lifetime.Application)); List <ServiceInfo> services = builder.GetServicesFrom(typeof(MyService)).ToList(); ServiceInfo[] expected = { new ServiceInfo(typeof(IMyService1), typeof(MyService), Lifetime.Application), new ServiceInfo(typeof(IMyService2), typeof(MyService), Lifetime.Application), }; AssertEx.AreEquivalent(services, this.comparer.Equals, expected); }
public void GetServicesFrom_ExportInterfacesMultipleInterfaces_RegisterMultipleContractTypes() { ServiceBuilder builder = new ServiceBuilder(t => t == typeof(MyService)); builder.ExportInterfaces(); List <ServiceInfo> services = builder.GetServicesFrom(typeof(MyService)).ToList(); ServiceInfo[] expected = { new ServiceInfo(typeof(IMyService1), typeof(MyService), Lifetime.Instance), new ServiceInfo(typeof(IMyService2), typeof(MyService), Lifetime.Instance), }; AssertEx.AreEquivalent(services, this.comparer.Equals, expected); }