Exemplo n.º 1
0
        public void SingleServiceMultipleBindingsTest()
        {
            StandardKernel kernel = new StandardKernel();
            var            module = new MockModule(r =>
            {
                r.Bind <IBaseClass>().To <ClassA>().InSingletonScope();
                r.Bind <IBaseClass>().To <ClassB>().InSingletonScope();
            });

            kernel.Load(module);
            List <IBinding> bindings = module.Bindings.ToList();

            int count = bindings.Where(b => b.Service.Equals(typeof(IBaseClass))).Count();

            Assert.AreEqual(2, count);
        }
Exemplo n.º 2
0
        public void SingleServicesBindingsTest()
        {
            StandardKernel kernel = new StandardKernel();
            var            module = new MockModule(r =>
            {
                r.Bind <ClassA>().ToSelf().InSingletonScope();
                r.Bind <ClassB>().ToSelf().InSingletonScope();
            });

            kernel.Load(module);
            List <IBinding> bindings = module.Bindings.ToList();

            Assert.AreEqual(2, bindings.Count);

            foreach (var type in new Type[] { typeof(ClassA), typeof(ClassB) })
            {
                bool bound = bindings.Where(b => b.Service.Equals(type)).Any();
                Assert.IsTrue(bound);
            }
        }