-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathIterablePublisherTest.cs
44 lines (37 loc) · 1.28 KB
/
IterablePublisherTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections;
using System.Collections.Generic;
using Xunit;
using Xunit.Abstractions;
using Reactive.Streams.TCK;
namespace Reactive.Streams.Example.Unicast.Tests
{
[TestFixture]
public class IterablePublisherTest : PublisherVerification<int?>
{
public IterablePublisherTest() : base(new TestEnvironment())
{
}
public override IPublisher<int?> CreatePublisher(long elements)
{
Assert.LessOrEqual(elements, MaxElementsFromPublisher);
return new NumberIterablePublisher(0, (int)elements);
}
public override IPublisher<int?> CreateFailedPublisher() => new FailedPublisher();
private sealed class FailedPublisher : AsyncIterablePublisher<int?>
{
public FailedPublisher() : base(new FailedEnumerable())
{
}
private sealed class FailedEnumerable : IEnumerable<int?>
{
public IEnumerator<int?> GetEnumerator()
{
throw new Exception("Error state signal!");
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
public override long MaxElementsFromPublisher { get; } = int.MaxValue;
}
}