IsRegistered() public méthode

public IsRegistered ( Type serviceType, object serviceKey ) : bool
serviceType System.Type
serviceKey object
Résultat bool
Exemple #1
0
        public void RegisterAndUnregisterFromSameScope()
        {
            var provider = new ServiceContainer();

            provider.Register <IService, ServiceOne>();

            Assert.True(provider.IsRegistered <IService>());

            Assert.True(provider.Unregister <IService>());

            Assert.False(provider.IsRegistered <IService>());
            var service = provider.Resolve <IService>();

            Assert.Null(service);
        }
Exemple #2
0
        public void IsRegisteredWithNullService()
        {
            var provider = new ServiceContainer();

            provider.Register <IService, DisposableService>();

            Assert.Throws <ArgumentNullException>(() => provider.IsRegistered(null));
        }
Exemple #3
0
        public void RegisterAndCheckService(Type serviceType, Type implementationType, object key)
        {
            var provider = new ServiceContainer();

            provider.Register(serviceType, implementationType, key);

            Assert.True(provider.IsRegistered(serviceType, key));
        }
Exemple #4
0
        public void IsRegisteredAfterDispose()
        {
            var provider = new ServiceContainer();

            provider.Register <IService, DisposableService>();

            provider.Dispose();

            Assert.Throws <InvalidOperationException>(() => provider.IsRegistered <IService>());
        }
Exemple #5
0
        public void RegisterAndUnregisterFromChildScope()
        {
            var provider = new ServiceContainer();

            provider.Register <IService, ServiceOne>();

            Assert.True(provider.IsRegistered <IService>());

            var scope = provider.OpenScope("b");

            Assert.NotNull(scope);
            Assert.True(scope.IsRegistered <IService>());

            Assert.True(scope.Unregister <IService>());

            var service = scope.Resolve <IService>();

            Assert.Null(service);
        }