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");
        }
Example #2
0
        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");
        }