public void ShouldResolve_Commands_Successfully()
        {
            var containerBuilder = new ContainerBuilder();
            containerBuilder.RegisterType(typeof(CommandTest)).AsSelf();
            ContextScopeProvider.RegisterTypes(containerBuilder);

            var httpContextMoq = new HttpContextMoq();
            var accessor = new Mock<IHttpContextAccessor>();
            accessor
                .Setup(a => a.GetCurrent())
                .Returns(() => httpContextMoq.HttpContextBase);

            var provider = new PerWebRequestContainerProvider(accessor.Object);
            var resolver = new DefaultCommandResolver(provider);

            var commandContext = new CommandContextTest();
            var command = resolver.ResolveCommand<CommandTest>(commandContext);
            Assert.IsNotNull(command);
            Assert.AreEqual(command.Context, commandContext);
        }
Example #2
0
        public void ShouldResolve_Commands_Successfully()
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterType(typeof(CommandTest)).AsSelf();
            ContextScopeProvider.RegisterTypes(containerBuilder);

            var httpContextMoq = new HttpContextMoq();
            var accessor       = new Mock <IHttpContextAccessor>();

            accessor
            .Setup(a => a.GetCurrent())
            .Returns(() => httpContextMoq.HttpContextBase);

            var provider = new PerWebRequestContainerProvider(accessor.Object);
            var resolver = new DefaultCommandResolver(provider);

            var commandContext = new CommandContextTest();
            var command        = resolver.ResolveCommand <CommandTest>(commandContext);

            Assert.IsNotNull(command);
            Assert.AreEqual(command.Context, commandContext);
        }