public void GetAllInstances_ServiceTypeWithNullImplementation_ThrowsActivationException()
        {
            var implementation            = ServiceImplementationInfo.CreateMultiple <ITestTypeWithErrors> (() => null);
            var serviceConfigurationEntry = new ServiceConfigurationEntry(typeof(ITestTypeWithErrors), implementation);

            var serviceLocator = CreateServiceLocator();

            serviceLocator.Register(serviceConfigurationEntry);

            Assert.That(
                () => serviceLocator.GetAllInstances(typeof(ITestTypeWithErrors)).ToArray(),
                Throws.TypeOf <ActivationException> ().With.Message.EqualTo(
                    "The registered factory returned null instead of an instance implementing the requested service type "
                    + "'Remotion.UnitTests.ServiceLocation.DefaultServiceLocatorTests.TestDomain.ITestTypeWithErrors'."));
        }
        public void GetAllInstances_ImplementationIsRegisteredAsFactoryWithInstanceLifetime()
        {
            TestImplementation1 expectedInstance = null;
            var serviceImplementation            = ServiceImplementationInfo.CreateMultiple(
                () => expectedInstance = new TestImplementation1(),
                LifetimeKind.InstancePerDependency);
            var serviceConfigurationEntry = new ServiceConfigurationEntry(typeof(ITestType), serviceImplementation);

            var serviceLocator = CreateServiceLocator();

            serviceLocator.Register(serviceConfigurationEntry);

            var instance1 = serviceLocator.GetAllInstances(typeof(ITestType)).SingleOrDefault();

            Assert.That(expectedInstance, Is.Not.Null);

            var instance2 = serviceLocator.GetAllInstances(typeof(ITestType)).SingleOrDefault();

            Assert.That(instance1, Is.Not.SameAs(instance2));
        }