Ejemplo n.º 1
0
        public void SuccessfullyResolvePipelineMiddleware()
        {
            var unityContainer = new UnityContainer();

            unityContainer.RegisterType <IFakeService, FakeService>();

            var unityMiddlewareResolver = new UnityMiddlewareResolver(unityContainer);
            var middleware = unityMiddlewareResolver.Resolve(typeof(FakePipelineMiddleware));

            middleware.Should().NotBeNull().And.BeOfType <FakePipelineMiddleware>();

            var initialEntity = new FakeEntity {
                Number = 2
            };

            ((FakePipelineMiddleware)middleware).Run(initialEntity, finalEntity => { finalEntity.Number.Should().Be(4); });
        }
Ejemplo n.º 2
0
        public void SuccessfullyResolveChainOfResponsibilityMiddleware()
        {
            var unityContainer = new UnityContainer();

            unityContainer.RegisterType <IFakeService, FakeService>();

            var unityMiddlewareResolver = new UnityMiddlewareResolver(unityContainer);
            var middleware = unityMiddlewareResolver.Resolve(typeof(FakeChainOfResponsibilityMiddleware));

            middleware.Should().NotBeNull().And.BeOfType <FakeChainOfResponsibilityMiddleware>();

            var initialEntity = new FakeEntity {
                Number = 2
            };
            var result = ((FakeChainOfResponsibilityMiddleware)middleware).Run(initialEntity, entity => entity.Number);

            result.Should().Be(4);
        }