public void GetInstance_ResolvingAnInstance_CallsTheInterceptorWithTheExpectedInitializationContext()
        {
            // Arrange
            var resolvedInstances = new InstanceInitializationDataCollection();

            var container = new Container();

            container.Options.RegisterResolveInterceptor(resolvedInstances.Intercept, Always);

            // Act
            container.GetInstance <Container>();

            InitializationContext actualContext = resolvedInstances.First().Context;

            // Assert
            Assert.AreSame(Lifestyle.Singleton, actualContext.Registration.Lifestyle, resolvedInstances.ToString());
            Assert.AreEqual(typeof(Container), actualContext.Registration.ImplementationType, resolvedInstances.ToString());
        }
        public void ContainerGetInstance_ResolvingAnInstance_CallsTheInterceptorWithADeletateThatReturnsTheExpectedInstance()
        {
            // Arrange
            var resolvedInstances = new InstanceInitializationDataCollection();

            var container = new Container();

            container.Options.RegisterResolveInterceptor(resolvedInstances.Intercept, Always);

            // Act
            container.GetInstance <Container>();

            object actualInstance = resolvedInstances.First().Instance;

            // Assert
            AssertThat.IsInstanceOfType(typeof(Container), actualInstance, resolvedInstances.ToString());
            Assert.AreEqual(1, resolvedInstances.Count, resolvedInstances.ToString());
        }
        public void ContainerGetInstance_ResolvingAnInstanceWithDependencies_OnlyCallsTheDelegateForThisRootInstance()
        {
            // Arrange
            var resolvedInstances = new InstanceInitializationDataCollection();

            var container = new Container();

            container.Options.RegisterResolveInterceptor(resolvedInstances.Intercept, Always);

            // Act
            container.GetInstance <Dep1>();

            object actualInstance = resolvedInstances.First().Instance;

            // Assert
            AssertThat.IsInstanceOfType(typeof(Dep1), actualInstance, resolvedInstances.ToString());
            Assert.AreEqual(1, resolvedInstances.Count, resolvedInstances.ToString());
        }