示例#1
0
        public void NormalExecutionReturnsExpectedObjects()
        {
            var settings = new ShellSettings {
                Name = ShellSettings.DefaultName
            };
            var descriptor = new ShellDescriptor {
                SerialNumber = 6655321
            };
            var blueprint          = new ShellBlueprint();
            var shellLifetimeScope = _container.BeginLifetimeScope("shell");
            var httpContext        = new StubHttpContext();

            _container.Mock <IShellDescriptorCache>()
            .Setup(x => x.Fetch(ShellSettings.DefaultName))
            .Returns(descriptor);

            _container.Mock <ICompositionStrategy>()
            .Setup(x => x.Compose(settings, descriptor))
            .Returns(blueprint);

            _container.Mock <IShellContainerFactory>()
            .Setup(x => x.CreateContainer(settings, blueprint))
            .Returns(shellLifetimeScope);

            _container.Mock <IShellDescriptorManager>()
            .Setup(x => x.GetShellDescriptor())
            .Returns(descriptor);

            _container.Mock <IWorkContextEvents>()
            .Setup(x => x.Started());

            _container.Mock <IHttpContextAccessor>()
            .Setup(x => x.Current())
            .Returns(default(HttpContextBase));

            var factory = _container.Resolve <IShellContextFactory>();

            var context = factory.CreateShellContext(settings);

            Assert.Same(context.Settings, settings);
            Assert.Same(context.Descriptor, descriptor);
            Assert.Same(context.Blueprint, blueprint);
            Assert.Same(context.LifetimeScope, shellLifetimeScope);
            //TODO why is same
            Assert.Same(context.Shell, shellLifetimeScope.Resolve <ISystemShell>());
        }