Ejemplo n.º 1
0
        public void InitializeToConstantIsCalledOnInstall()
        {
            var eventCounter        = new InjectEventCounter();
            var initializationAware = new InitializationAware();

            var container = Container.Create();

            container.Bind <InjectEventCounter>().ToConstant(eventCounter).AsCached().OnInstall();
            container.Bind <InitializationAware>().ToConstant(initializationAware).AsCached().OnInstall();

            Assert.Equal(0, eventCounter.Initialize);

            var resolver = container.Install();

            Assert.Equal(1, eventCounter.Initialize);
        }
Ejemplo n.º 2
0
        public void InitializeToConstantIsCalledOnRequest_EmptyParent()
        {
            var eventCounter        = new InjectEventCounter();
            var initializationAware = new InitializationAware();

            var container = Container.Create(TestHelper.CreateEmptyContainer(true));

            container.Bind <InjectEventCounter>().ToConstant(eventCounter).AsCached().OnInstall();
            container.Bind <InitializationAware>().ToConstant(initializationAware).AsCached().OnRequest();

            Assert.Equal(0, eventCounter.Initialize);

            var resolver = container.Install();

            Assert.Equal(0, eventCounter.Initialize);

            var initializationAware2 = resolver.Get <InitializationAware>();

            Assert.Equal(1, eventCounter.Initialize);
        }