Esempio n. 1
0
 public static async Task PushAsync <TMessage>(this IWebhostFixture fixture, TMessage message, CancellationToken ct = default)
 {
     var publisher = fixture.GetService <IMessagePublisher>();
     await publisher.PublishAsync(new ClientMessage
     {
         Type      = message.GetType().Name,
         Payload   = message,
         ClientIds = new List <string>()
     }, ct);
 }
Esempio n. 2
0
        public static Task Intercept <TIncomming, TOutgoing>(this IWebhostFixture fixture, Func <TIncomming, CancellationToken, Task <TOutgoing> > interceptor)
        {
            var publisher = fixture.GetService <IMessagePublisher>();

            return(fixture.Intercept <TIncomming>(async(incomming, token) =>
            {
                var outgoing = await interceptor(incomming, token);
                await publisher.PublishAsync(outgoing, token);
            }));
        }
 public static async Task PublishAsync <TMessage>(this IWebhostFixture fixture, TMessage message, CancellationToken ct = default)
 {
     var publisher = fixture.GetService <IMessagePublisher>();
     await publisher.PublishAsync(message, ct);
 }
Esempio n. 4
0
 public static Task Intercept <TMessage>(this IWebhostFixture fixture, Func <TMessage, CancellationToken, Task> interceptor)
 {
     return(fixture
            .GetService <IMessageSubscriber>()
            .SubscribeAsync(interceptor));
 }