Skip to content

Commit

Permalink
Test disposal order of Finally
Browse files Browse the repository at this point in the history
  • Loading branch information
quinmars authored and Oren Novotny committed Aug 1, 2019
1 parent 31e6aa8 commit 0ee2035
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Reactive;
using System.Reactive.Linq;
using Microsoft.Reactive.Testing;
using Xunit;
Expand Down Expand Up @@ -142,5 +143,48 @@ public void Finally_Throw()
);
}

[Fact]
public void Finally_DisposeOrder_Empty()
{
var order = "";
Observable
.Empty<Unit>()
.Finally(() => order += "1")
.Finally(() => order += "2")
.Finally(() => order += "3")
.Subscribe();

Assert.Equal("123", order);
}

[Fact]
public void Finally_DisposeOrder_Return()
{
var order = "";
Observable
.Return(Unit.Default)
.Finally(() => order += "1")
.Finally(() => order += "2")
.Finally(() => order += "3")
.Subscribe();

Assert.Equal("123", order);
}

[Fact]
public void Finally_DisposeOrder_Never()
{
var order = "";
var d = Observable
.Never<Unit>()
.Finally(() => order += "1")
.Finally(() => order += "2")
.Finally(() => order += "3")
.Subscribe();

d.Dispose();

Assert.Equal("123", order);
}
}
}

0 comments on commit 0ee2035

Please sign in to comment.