public void GetInstanceThrowsActivationExceptionWhenComponentNotFound()
        {
            var container = new ContainerMock();
            var adapter   = new CommonServiceLocatorAdapter(container);

            container.AddExpectation("Resolve", () =>
            {
                throw new ServiceNotFoundException(typeof(IService));
            });
            Assert.Throws <ActivationException>(() => adapter.GetInstance <IService>());
        }
        public void GetInstanceThrowsActivationExceptionWhenComponentNotFound()
        {
            var container = new ContainerMock();
            var adapter = new CommonServiceLocatorAdapter(container);
            container.AddExpectation("Resolve", () =>
                                                           {
                                                               throw new ServiceNotFoundException(typeof(IService));

                                                           });
            Assert.Throws<ActivationException>(() => adapter.GetInstance<IService>());
        }
        public void GetInstanceTranslatesToResolveOnContainer()
        {
            var container = new ContainerMock();
            var weakResolveWasCalled = false;
            container.AddExpectation("Resolve", () =>
                                                    {
                                                        weakResolveWasCalled = true;
                                                        return new ClassWithNoDependencies();
                                                    });

            var adapter = new CommonServiceLocatorAdapter(container);
            adapter.GetInstance<IService>();

            Assert.True(weakResolveWasCalled);
        }
        public void GetInstanceTranslatesToResolveOnContainer()
        {
            var container            = new ContainerMock();
            var weakResolveWasCalled = false;

            container.AddExpectation("Resolve", () =>
            {
                weakResolveWasCalled = true;
                return(new ClassWithNoDependencies());
            });

            var adapter = new CommonServiceLocatorAdapter(container);

            adapter.GetInstance <IService>();

            Assert.True(weakResolveWasCalled);
        }