public void CanGetServiceByInterface() { Assert.True(ServiceProvider.Current is UnityServiceProvider, "Not the Unity service provider"); var service = new FakeServiceA(); ServiceCollection.Current.AddSingleton <IFakeService, FakeServiceA>(service); Assert.True(ServiceProvider.Current.Get <IFakeService>() != null); Assert.True(ServiceProvider.Current.Get <IFakeService>() == service); }
public void CanGetServiceByInterface() { Assert.True(BasicServiceProvider.SharedInstance.Count == 0, "Service Provider Not Empty"); Assert.True(ServiceProvider.Current == BasicServiceProvider.SharedInstance, "Not the basic service provider"); var service = new FakeServiceA(); ServiceCollection.Current.AddSingleton <IFakeService, FakeServiceA>(service); Assert.True(ServiceProvider.Current.Get <IFakeService>() != null); Assert.True(ServiceProvider.Current.Get <IFakeService>() == service); }
public void CanGetAllServicesForInterface() { Assert.True(ServiceProvider.Current is UnityServiceProvider, "Not the Unity service provider"); var serviceA = new FakeServiceA(); ServiceCollection.Current.AddSingleton(serviceA); var serviceB = new FakeServiceB(); ServiceCollection.Current.AddSingleton(serviceB); var serviceC = new FakeServiceC(); ServiceCollection.Current.AddSingleton(serviceC); List <IFakeService> list = new List <IFakeService>(); ServiceProvider.Current.GetAll(list); Assert.True(list.Count == 2, $"IFakeService count = {list.Count} but we expected 2"); }
public void CanGetAllServicesForInterface() { Assert.True(BasicServiceProvider.SharedInstance.Count == 0, "Service Provider Not Empty"); Assert.True(ServiceProvider.Current == BasicServiceProvider.SharedInstance, "Not the basic service provider"); var serviceA = new FakeServiceA(); ServiceCollection.Current.AddSingleton(serviceA); var serviceB = new FakeServiceB(); ServiceCollection.Current.AddSingleton(serviceB); var serviceC = new FakeServiceC(); ServiceCollection.Current.AddSingleton(serviceC); List <IFakeService> list = new List <IFakeService>(); ServiceProvider.Current.GetAll(list); Assert.True(list.Count == 2, $"IFakeService count = {list.Count} but we expected 2"); }