public void CreateHandler_WhenContractTypeNotSatisfiedByObjectType_Throws()
        {
            var factory = new SingletonHandlerFactory();
            var dependencyResolver = MockRepository.GenerateStub<IObjectDependencyResolver>();

            var ex = Assert.Throws<RuntimeException>(() => factory.CreateHandler(dependencyResolver,
                typeof(IService), typeof(ComponentThatDoesNotImplementIService), new PropertySet()));
            Assert.AreEqual(string.Format("Could not satisfy contract of type '{0}' by creating an instance of type '{1}'.",
                typeof(IService), typeof(ComponentThatDoesNotImplementIService)), ex.Message);
        }
        public void CreateHandler_WhenArgumentsValid_ReturnsAHandlerThatGeneratesTheSameComponentInstanceEachTime()
        {
            var factory = new SingletonHandlerFactory();
            var dependencyResolver = MockRepository.GenerateStub<IObjectDependencyResolver>();

            var handler = factory.CreateHandler(dependencyResolver,
                typeof(IService), typeof(Component), new PropertySet());

            var instance1 = handler.Activate();
            Assert.IsInstanceOfType<Component>(instance1);

            var instance2 = handler.Activate();
            Assert.AreSame(instance1, instance2, "Should return same instance each time because the component is considered a singleton.");
        }