コード例 #1
0
ファイル: InMemoryBusEngineTests.cs プロジェクト: simgu/Nybus
        public async Task Sent_commands_are_received([Frozen] IEnvelopeService envelopeService, InMemoryBusEngine sut, CommandMessage <FirstTestCommand> testMessage, IFixture fixture, string headerKey, string headerValue)
        {
            fixture.Customize <Envelope>(c => c
                                         .With(p => p.Type, testMessage.Type)
                                         .With(p => p.Headers, testMessage.Headers)
                                         .With(p => p.Content)
                                         .With(p => p.MessageId, testMessage.MessageId)
                                         .With(p => p.MessageType, testMessage.MessageType)
                                         );

            Mock.Get(envelopeService).Setup(p => p.CreateEnvelope(It.IsAny <CommandMessage <FirstTestCommand> >())).ReturnsUsingFixture(fixture);
            Mock.Get(envelopeService).Setup(p => p.CreateCommandMessage(It.IsAny <Envelope>(), It.IsAny <Type>())).Returns(testMessage);

            testMessage.Headers[headerKey] = headerValue;

            sut.SubscribeToCommand <FirstTestCommand>();

            var sequence = await sut.StartAsync().ConfigureAwait(false);

            var items = sequence.DumpInList();

            await sut.SendMessageAsync(testMessage);

            Assert.That(items.First().Headers, Contains.Key(headerKey));
            Assert.That(items.First().Headers[headerKey], Is.EqualTo(headerValue));
        }
コード例 #2
0
 public EnvelopeController(IEnvelopeService service, IExchangeRateService exRateService,
                           IExchangeRateHttpService exRateHttpService, ICurrencyService currService)
 {
     envelopeService         = service;
     exchangeRateService     = exRateService;
     exchangeRateHttpService = exRateHttpService;
     currencyService         = currService;
 }
コード例 #3
0
 public ImportDataController(IDataImportService dataImportService, IProjectService projService,
                             IEnvelopeService envpService, IOrganizationTypeService orgTypeService, IExchangeRateService exRateService,
                             IExchangeRateHttpService exRateHttpService, IWebHostEnvironment hostEnvironment,
                             IProjectMembershipService projectMembshipService)
 {
     service                 = dataImportService;
     projectService          = projService;
     envelopeService         = envpService;
     organizationTypeService = orgTypeService;
     ratesService            = exRateService;
     ratesHttpService        = exRateHttpService;
     hostingEnvironment      = hostEnvironment;
     service.SetDirectoryPath(hostingEnvironment.WebRootPath);
     projectMembershipService = projectMembshipService;
 }
コード例 #4
0
ファイル: InMemoryBusEngineTests.cs プロジェクト: simgu/Nybus
        public async Task Sent_events_are_received([Frozen] IEnvelopeService envelopeService, InMemoryBusEngine sut, EventMessage <FirstTestEvent> testMessage, IFixture fixture)
        {
            fixture.Customize <Envelope>(c => c
                                         .With(p => p.Type, testMessage.Type)
                                         .With(p => p.Headers, testMessage.Headers)
                                         .With(p => p.Content)
                                         .With(p => p.MessageId, testMessage.MessageId)
                                         .With(p => p.MessageType, testMessage.MessageType)
                                         );

            Mock.Get(envelopeService).Setup(p => p.CreateEnvelope(It.IsAny <EventMessage <FirstTestEvent> >())).ReturnsUsingFixture(fixture);
            Mock.Get(envelopeService).Setup(p => p.CreateEventMessage(It.IsAny <Envelope>(), It.IsAny <Type>())).Returns(testMessage);

            sut.SubscribeToEvent <FirstTestEvent>();

            var sequence = await sut.StartAsync().ConfigureAwait(false);

            var items = sequence.DumpInList();

            await sut.SendMessageAsync(testMessage);

            Assert.That(items.First(), Is.EqualTo(testMessage).Using <EventMessage <FirstTestEvent> >((x, y) => x.MessageId == y.MessageId));
        }
コード例 #5
0
 public InMemoryBusEngine(IMessageDescriptorStore messageDescriptorStore, IEnvelopeService envelopeService)
 {
     _messageDescriptorStore = messageDescriptorStore ?? throw new ArgumentNullException(nameof(messageDescriptorStore));
     _envelopeService        = envelopeService ?? throw new ArgumentNullException(nameof(envelopeService));
 }
コード例 #6
0
        //Use Case Driven - Adding new envelope
        public void addNewEnvelope(Envelope envelope)
        {
            IEnvelopeService envelopeSvc = (IEnvelopeService)GetService(typeof(IEnvelopeService).Name);

            envelopeSvc.createEnvelopeData(envelope);
        }//end addNewEnvelope
コード例 #7
0
 public EnvelopeController(IEnvelopeService envelopeService)
 {
     _envelopeService = envelopeService;
 }
コード例 #8
0
ファイル: InMemoryBusEngineTests.cs プロジェクト: simgu/Nybus
        public async Task Events_are_ignored_if_not_registered([Frozen] IMessageDescriptorStore messageDescriptorStore, [Frozen] IEnvelopeService envelopeService, InMemoryBusEngine sut, EventMessage <FirstTestEvent> testMessage, IFixture fixture)
        {
            fixture.Customize <Envelope>(c => c
                                         .With(p => p.Type, testMessage.Type)
                                         .With(p => p.Headers, testMessage.Headers)
                                         .With(p => p.Content)
                                         .With(p => p.MessageId, testMessage.MessageId)
                                         .With(p => p.MessageType, testMessage.MessageType)
                                         );

            Mock.Get(envelopeService).Setup(p => p.CreateEnvelope(It.IsAny <EventMessage <FirstTestEvent> >())).ReturnsUsingFixture(fixture);
            Mock.Get(envelopeService).Setup(p => p.CreateEventMessage(It.IsAny <Envelope>(), It.IsAny <Type>())).Returns(testMessage);

            var sequence = await sut.StartAsync().ConfigureAwait(false);

            var items = sequence.DumpInList();

            await sut.SendMessageAsync(testMessage);

            Assert.That(items, Is.Empty);
        }