Esempio n. 1
0
        public async Task can_decorate_a_handler_without_response_to_return_default_response()
        {
            // given

            var handlerMock = new Mock <IHandler <RequestWithNoResponse> >();

            var builder = new ContainerBuilder();

            BuildRegistration.Instance(handlerMock.Object)
            .WithDefaultResponse()
            .RegisterAsHandlerIn(builder);

            builder.RegisterType <HandlerMediator>()
            .AsSelf();

            using (var container = builder.Build())
            {
                var request = new RequestWithNoResponse();

                // when

                var response = await container
                               .Resolve <HandlerMediator>()
                               .Handle(request);

                // then

                response.Should().BeSameAs(Nothing.Value);

                handlerMock.Verify(handler => handler.Handle(request), Times.Once);
            }
        }
Esempio n. 2
0
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <UpdateEnvironmentsHandler>()
     .WithDefaultResponse()
     .InProjectLock()
     .RegisterAsHandlerIn(builder);
 }
Esempio n. 3
0
        public void can_map_a_resolved_type()
        {
            // given

            var builder = new ContainerBuilder();

            var someInstance = new SomeType();

            BuildRegistration.Instance(someInstance)
            .Select(someType => new SomeTypeWrapper {
                SomeType = someType
            })
            .RegisterIn(builder);

            using (var container = builder.Build())
            {
                // when

                var result = container.Resolve <SomeTypeWrapper>();

                // then

                result.SomeType.Should().BeSameAs(someInstance);
            }
        }
Esempio n. 4
0
        public void set_up()
        {
            _handlerWithResponseMock   = new Mock <IHandler <RequestWithResponse, Response> >();
            _handlerWithNoResponseMock = new Mock <IHandler <RequestWithNoResponse, Nothing> >();

            var builder = new ContainerBuilder();

            BuildRegistration.Instance(_handlerWithResponseMock.Object)
            .RegisterAsHandlerIn(builder);

            BuildRegistration.Instance(_handlerWithNoResponseMock.Object)
            .RegisterAsHandlerIn(builder);

            builder.RegisterType <HandlerMediator>();

            _container = builder.Build();

            _mediator = _container.Resolve <HandlerMediator>();
        }
Esempio n. 5
0
        public void can_resolve_an_instance()
        {
            // given

            var builder = new ContainerBuilder();

            var someInstance = new SomeType();

            BuildRegistration.Instance(someInstance)
            .RegisterIn(builder);

            using (var container = builder.Build())
            {
                // when

                var result = container.Resolve <SomeType>();

                // then

                result.Should().BeSameAs(someInstance);
            }
        }
Esempio n. 6
0
        public void can_resolve_a_type()
        {
            // given

            var builder = new ContainerBuilder();

            builder.RegisterType <SomeType>();

            BuildRegistration.Type <SomeType>()
            .RegisterIn(builder)
            .As <ISomeInterface>();

            using (var container = builder.Build())
            {
                // when

                var result = container.Resolve <ISomeInterface>();

                // then

                result.Should().BeOfType <SomeType>();
            }
        }
Esempio n. 7
0
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <GetLastPackageHandler>()
     .InProjectLock()
     .RegisterAsHandlerIn(builder);
 }
Esempio n. 8
0
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <GetComponentsForUpdateHandler>()
     .RegisterAsHandlerIn(builder);
 }
Esempio n. 9
0
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <UpdateComponentsHandler>()
     .WithDefaultResponse()
     .RegisterAsHandlerIn(builder);
 }
Esempio n. 10
0
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <GetPackagesListHandler>()
     .RegisterAsHandlerIn(builder);
 }
Esempio n. 11
0
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <ListProjectsHandler>()
     .RegisterAsHandlerIn(builder);
 }
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <GetDeploymentDetailsHandler>()
     .RegisterAsHandlerIn(builder);
 }
Esempio n. 13
0
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <CreateProjectHandler>()
     .WithDefaultResponse()
     .RegisterAsHandlerIn(builder);
 }
Esempio n. 14
0
 protected override void Load(ContainerBuilder builder)
 {
     BuildRegistration.Type <GetDashboardHandler>()
     .RegisterAsHandlerIn(builder);
 }