Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ContinueAfter Unit Tests
public class TheContinueAfterMethod
{
[Fact]
public void RunsNextItemAfterCompletion()
{
var stringSequence = new[] { "one", "two", "three" }.ToObservable();
var observed = new List<String>();
Observable.Return(123).ContinueAfter(() => stringSequence)
.Subscribe(observed.Add);
observed[0].ShouldEqual("one");
observed[1].ShouldEqual("two");
observed[2].ShouldEqual("three");
}
[Fact]
public void RunsNextItemOnlyOnceAfterCompletion()
{
var stringSequence = new[] { "uno", "dos", "tres" }.ToObservable();
var initialSequence = new[] { 1, 2, 3, 4 }.ToObservable();
int callCount = 0;
var observed = new List<String>();
initialSequence.ContinueAfter(() =>
{
callCount++;
return stringSequence;
})
.Subscribe(observed.Add);
callCount.ShouldEqual(1);
observed[0].ShouldEqual("uno");
observed[1].ShouldEqual("dos");
observed[2].ShouldEqual("tres");
}
[Fact]
public void RunsNextItemAfterObservableCompletesWithEmptySequence()
{
var stringSequence = new[] { "하나", "", "" }.ToObservable();
var observed = new List<String>();
Observable.Empty<int>()
.ContinueAfter(() => stringSequence)
.Subscribe(observed.Add);
observed[0].ShouldEqual("하나");
observed[1].ShouldEqual("");
observed[2].ShouldEqual("");
}
[Fact]
public void ForwardsExceptionsFromOriginalObservable()
{
var stringSequence = new[] { "하나", "", "" }.ToObservable();
var observed = new List<String>();
Exception caught = null;
Observable.Throw<int>(new Exception("Will we catch this?"))
.ContinueAfter(() => stringSequence)
.Subscribe(observed.Add, e => caught = e);
observed.Count.ShouldEqual(0);
caught.Message.ShouldEqual("Will we catch this?");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.