-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BehaviorSubject mistakenly refers to check_unsubscribed as a class me…
…thod
- Loading branch information
Bittrance
committed
Oct 21, 2017
1 parent
baf10b6
commit 153da58
Showing
2 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
|
||
require 'test_helper' | ||
|
||
class TestBehaviorSubject < Minitest::Test | ||
def test_subscriber_notified_on_change | ||
value = 0 | ||
subject = Rx::BehaviorSubject.new 0 | ||
subject.as_observable.subscribe { |update| value = update } | ||
subject.on_next 1 | ||
assert_equal 1, value | ||
end | ||
|
||
def test_multiple_observers_notified_on_change | ||
value1 = 0 | ||
value2 = 0 | ||
subject = Rx::BehaviorSubject.new 0 | ||
subject.as_observable.subscribe { |update| value1 = update } | ||
subject.as_observable.subscribe { |update| value2 = update } | ||
subject.on_next 1 | ||
assert_equal 1, value1 | ||
assert_equal 1, value2 | ||
end | ||
|
||
def test_errors_on_next_when_unsubscribed | ||
subject = Rx::BehaviorSubject.new 0 | ||
subject.as_observable.subscribe { } | ||
subject.unsubscribe | ||
assert_raises(RuntimeError) { subject.on_next 1 } | ||
end | ||
end |