public void ExecutionContextScopeDispose_TwoScopedRegistationsForTheSameServiceType_DisposesBothInstances()
        {
            // Arrange
            var disposedInstances = new HashSet <object>();

            var lifestyle = new ExecutionContextScopeLifestyle();

            var container = new Container();

            var reg1 = lifestyle.CreateRegistration <ICommand, DisposableCommand>(container);
            var reg2 = lifestyle.CreateRegistration <ICommand, DisposableCommand>(container);

            container.AppendToCollection(typeof(ICommand), reg1);
            container.AppendToCollection(typeof(ICommand), reg2);

            using (container.BeginExecutionContextScope())
            {
                var commands = container.GetAllInstances <ICommand>().Cast <DisposableCommand>().ToArray();

                Assert.AreNotSame(commands[0], commands[1], "Test setup failed.");

                commands[0].Disposing += sender => disposedInstances.Add(sender);
                commands[1].Disposing += sender => disposedInstances.Add(sender);

                // Act
            }

            // Assert
            Assert.AreEqual(2, disposedInstances.Count, "Two instances were expected to be disposed.");
        }
        public void ExecutionContextScope_TwoScopedRegistationsForTheSameServiceType_CreatesTwoInstances()
        {
            // Arrange
            var lifestyle = new ExecutionContextScopeLifestyle();

            var container = new Container();

            var reg1 = lifestyle.CreateRegistration <ICommand, DisposableCommand>(container);
            var reg2 = lifestyle.CreateRegistration <ICommand, DisposableCommand>(container);

            container.AppendToCollection(typeof(ICommand), reg1);
            container.AppendToCollection(typeof(ICommand), reg2);

            using (container.BeginExecutionContextScope())
            {
                // Act
                var commands = container.GetAllInstances <ICommand>().Cast <DisposableCommand>().ToArray();

                // Assert
                Assert.AreNotSame(commands[0], commands[1], "Two instances were expected.");
            }
        }