예제 #1
0
        public async Task TestSendCompletes()
        {
            var retryPolicy          = new RetryPolicy(new ErrorDetectionStrategy(_ => true), new FixedInterval(3, TimeSpan.FromMilliseconds(10)));
            var items                = new[] { 1, 2, 3, 4, 5, 6 };
            var testSink             = new PartialFailureSink <int>(new Exception());
            var sink                 = new RetryingSink <int>(testSink, retryPolicy);
            ISinkResult <int> result = await sink.ProcessAsync(items, CancellationToken.None);

            await sink.CloseAsync(CancellationToken.None);

            Assert.True(result.IsSuccessful);
            Assert.Equal(new List <int>(items), result.Succeeded);
        }
예제 #2
0
        public async Task TestFailure()
        {
            var retryPolicy          = new RetryPolicy(new ErrorDetectionStrategy(_ => true), new FixedInterval(2, TimeSpan.FromMilliseconds(10)));
            var items                = new[] { 1, 2, 3, 4, 5, 6 };
            var testSink             = new PartialFailureSink <int>(new Exception());
            var sink                 = new RetryingSink <int>(testSink, retryPolicy);
            ISinkResult <int> result = await sink.ProcessAsync(items, CancellationToken.None);

            Assert.False(result.IsSuccessful);
            Assert.Equal(new List <int> {
                1, 2, 3, 4, 5
            }, result.Succeeded);
            Assert.Equal(new List <int> {
                6
            }, result.Failed);
            Assert.Equal(new List <InvalidDetails <int> >(), result.InvalidDetailsList);
        }