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); } }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <UpdateEnvironmentsHandler>() .WithDefaultResponse() .InProjectLock() .RegisterAsHandlerIn(builder); }
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); } }
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>(); }
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); } }
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>(); } }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <GetLastPackageHandler>() .InProjectLock() .RegisterAsHandlerIn(builder); }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <GetComponentsForUpdateHandler>() .RegisterAsHandlerIn(builder); }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <UpdateComponentsHandler>() .WithDefaultResponse() .RegisterAsHandlerIn(builder); }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <GetPackagesListHandler>() .RegisterAsHandlerIn(builder); }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <ListProjectsHandler>() .RegisterAsHandlerIn(builder); }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <GetDeploymentDetailsHandler>() .RegisterAsHandlerIn(builder); }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <CreateProjectHandler>() .WithDefaultResponse() .RegisterAsHandlerIn(builder); }
protected override void Load(ContainerBuilder builder) { BuildRegistration.Type <GetDashboardHandler>() .RegisterAsHandlerIn(builder); }