コード例 #1
0
        public void GetServices_BindingDefined_ShouldReturnDefined()
        {
            var services = _resolver.GetServices(typeof(Intf1)).ToArray();

            Assert.AreEqual(1, services.Length);
            Assert.IsInstanceOf <Class1>(services[0]);
        }
コード例 #2
0
        public void GetServices_returns_empty_collection_when_none_registered()
        {
            var kernel = new StandardKernel();
            var resolver = new NinjectDependencyResolver(kernel);

            var result = resolver.GetServices(typeof(IDateTime));
            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Count());
        }
コード例 #3
0
        public void GetServices_returns_empty_collection_when_none_registered()
        {
            var kernel   = new StandardKernel();
            var resolver = new NinjectDependencyResolver(kernel);

            var result = resolver.GetServices(typeof(IDateTime));

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Count());
        }
コード例 #4
0
ファイル: Global.asax.cs プロジェクト: RayKwon/MyStory
        private void CreateAutoMapping()
        {
            NinjectDependencyResolver resolver = new NinjectDependencyResolver();

            var mappers = resolver.GetServices<IMapper>();

            foreach (var mapper in mappers)
            {
                mapper.Execute();
            }
        }
コード例 #5
0
        public void GetServices_returns_multiple_instances_when_some_registered()
        {
            var kernel = new StandardKernel();
            var resolver = new NinjectDependencyResolver(kernel);

            kernel.Bind<IDateTime>().To<DateTimeAdapter>();
            kernel.Bind<IDateTime>().ToConstant(new Mock<IDateTime>().Object);

            var result = resolver.GetServices(typeof(IDateTime));
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
        }
コード例 #6
0
        public void GetServices_returns_multiple_instances_when_some_registered()
        {
            var kernel   = new StandardKernel();
            var resolver = new NinjectDependencyResolver(kernel);

            kernel.Bind <IDateTime>().To <DateTimeAdapter>();
            kernel.Bind <IDateTime>().ToConstant(new Mock <IDateTime>().Object);

            var result = resolver.GetServices(typeof(IDateTime));

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
        }