public async Task Build_Merge_Producer_Test()
        {
            var producerA =
                _builder.UseChannel(_channel)
                .Partition("Organizations")
                .Shard("Org: #RedSocks")
                .AddInterceptor(_rawAsyncInterceptor);

            var producerB =
                _builder.UseTestProducerChannel()
                .Partition("NGOs")
                .Shard("NGO #2782228")
                .UseSegmentation(_segmentationStrategy);

            var producerC =
                _builder.UseChannel(_channel)
                .Partition("Fans")
                .Shard("Geek: @someone")
                .UseSegmentation(_otherSegmentationStrategy);


            ISequenceOperationsProducer producer =
                _builder
                .Merge(producerA, producerB, producerC)
                .UseSegmentation(_postSegmentationStrategy)
                .Build <ISequenceOperationsProducer>();

            await producer.RegisterAsync(new User());

            await producer.LoginAsync("admin", "1234");

            await producer.EarseAsync(4335);
        }
        public async Task Build_Interceptor_Producer_Test()
        {
            ISequenceOperationsProducer producer =
                _builder.UseChannel(_channel)
                .Partition("Organizations")
                .Shard("Org: #RedSocks")
                .AddInterceptor(_rawInterceptor)
                .AddInterceptor(_rawAsyncInterceptor)
                .UseSegmentation(_segmentationStrategy)
                .UseSegmentation(_otherSegmentationStrategy)
                .Build <ISequenceOperationsProducer>();

            await producer.RegisterAsync(new User());

            await producer.LoginAsync("admin", "1234");

            await producer.EarseAsync(4335);
        }
예제 #3
0
        public async Task Build_API_Serializer_Producer_Test()
        {
            var option = new EventSourceOptions(_serializer);

            ISequenceOperationsProducer producer =
                _builder.UseChannel(_channel)
                .WithOptions(option)
                .Partition("Organizations")
                .Shard("Org: #RedSocks")
                .WithLogger(_logger)
                .Build <ISequenceOperationsProducer>();

            await producer.RegisterAsync(new User());

            await producer.LoginAsync("admin", "1234");

            await producer.EarseAsync(4335);
        }
예제 #4
0
        public async Task Build_Serializer_Producer_Test()
        {
            //var producerOption = new EventSourceOptions(_serializer);

            ISequenceOperationsProducer producer =
                _producerBuilder.UseChannel(_producerChannel)
                //.WithOptions(producerOption)
                .Partition("Organizations")
                .Shard("Org: #RedSocks")
                .Build <ISequenceOperationsProducer>();

            await producer.RegisterAsync(new User());

            await producer.LoginAsync("admin", "1234");

            await producer.EarseAsync(4335);

            //var consumerOptions = new EventSourceConsumerOptions(serializer: _serializer);

            var cts = new CancellationTokenSource();
            IAsyncDisposable subscription =
                _consumerBuilder.UseChannel(_consumerChannel)
                //.WithOptions(consumerOptions)
                .WithCancellation(cts.Token)
                .Partition("Organizations")
                .Shard("Org: #RedSocks")
                .Subscribe(meta => _subscriber);

            ch.Writer.Complete();
            await subscription.DisposeAsync();

            await ch.Reader.Completion;

            A.CallTo(() => _subscriber.RegisterAsync(A <User> .Ignored))
            .MustHaveHappenedOnceExactly();
            A.CallTo(() => _subscriber.LoginAsync("admin", "1234"))
            .MustHaveHappenedOnceExactly();
            A.CallTo(() => _subscriber.EarseAsync(4335))
            .MustHaveHappenedOnceExactly();
        }