public void GIVEN_null_configuration_is_provided_WHEN_listened_a_message_THEN_it_does_nothing() { var dependencies = new MessageHandlerDependenciesHolder<CurrencyAggregate>(); var aggregate = GenerateRandomAggregate(); var handlersConfig = new List<MessageHandlerConfiguration>(); dependencies.HostConfiguration.MessagesHandlers.Returns(handlersConfig); dependencies.MessageDecrypter.Decrypt<CurrencyAggregate>(Arg.Any<NotNullable<BaseEvent>>()).Returns(aggregate); var sut = new CurrencyMessageHandler( dependencies.RepositoryFactory, dependencies.MessageDecrypter, dependencies.HostConfiguration, dependencies.HostServiceEvents); var message = TestsHelpers.GenerateRandomMessage("RegisteredCurrency"); dependencies.HostServiceEvents.AddIncommingEvent(message); dependencies.Repository.DidNotReceive().Save(Arg.Any<CurrencyAggregate>()); }
public void GIVEN_a_RegisteredCurrency_message_WHEN_listened_THEN_the_aggregate_is_saved_in_the_repository() { var dependencies = new MessageHandlerDependenciesHolder<CurrencyAggregate>(); var aggregate = GenerateRandomAggregate(); var handlersConfig = new List<MessageHandlerConfiguration>(); handlersConfig.Add(new MessageHandlerConfigurationFake("CurrencyMessageHandler", new List<ESynchroSystem>() { ESynchroSystem.PortalPaciente })); dependencies.HostConfiguration.MessagesHandlers.Returns(handlersConfig); dependencies.MessageDecrypter.Decrypt<CurrencyAggregate>(Arg.Any<NotNullable<BaseEvent>>()).Returns(aggregate); var sut = new CurrencyMessageHandler( dependencies.RepositoryFactory, dependencies.MessageDecrypter, dependencies.HostConfiguration, dependencies.HostServiceEvents); var message = TestsHelpers.GenerateRandomMessage("RegisteredCurrency"); dependencies.HostServiceEvents.AddIncommingEvent(message); dependencies.Repository.Received(1).Save(aggregate); }