public void SimpleServiceResolver_can_store_class_and_interface()
        {
            IServiceResolver resolver          = GetResolver();
            ITestService     expectedInterface = new TestService();
            TestService      expectedClass     = new TestService();

            resolver.RegisterService <ITestService>(() => expectedInterface);
            resolver.RegisterService <TestService>(() => expectedClass);
            ITestService actualInterface = resolver.GetService <ITestService>();
            TestService  actualClass     = resolver.GetService <TestService>();

            Assert.IsNotNull(actualInterface);
            Assert.IsNotNull(actualClass);
            Assert.AreNotSame(actualInterface, actualClass);
            Assert.AreEqual(expectedInterface, actualInterface);
            Assert.AreEqual(expectedClass, actualClass);
        }
        public void SimpleServiceResolver_store_correct_type()
        {
            IServiceResolver resolver = GetResolver();

            resolver.RegisterService <ITestService>(() => new TestService());
            var actual = resolver.QueryService <TestService>();

            Assert.IsNull(actual);
        }
        public void SimpleServiceResolver_registration_and_get_works()
        {
            IServiceResolver resolver = GetResolver();

            resolver.RegisterService <ITestService>(() => new TestService());
            var actual = resolver.GetService <ITestService>();

            Assert.IsInstanceOfType(actual, typeof(ITestService));
            Assert.IsInstanceOfType(actual, typeof(TestService));
        }
        public void NinjectServiceResolver_registration_and_query_works()
        {
            IServiceResolver resolver = GetResolver();

            resolver.RegisterService <ITestService>(() => new TestService());
            var actual = resolver.QueryService <ITestService>();

            Assert.IsNotNull(actual);
            Assert.IsInstanceOfType(actual, typeof(ITestService));
            Assert.IsInstanceOfType(actual, typeof(TestService));
        }
 public static void RegisterService(this IServiceResolver resolver, IServiceInfo serviceInfo)
 {
     resolver.RegisterService(serviceInfo.InterfaceType, () => serviceInfo.Create());
 }
 public static void RegisterService <T>(this IServiceResolver resolver, Func <IService> serviceProvider) where T : IService
 {
     resolver.RegisterService(typeof(T), serviceProvider);
 }