1919namespace ReactiveMarbles . Mvvm . Tests ;
2020
2121/// <summary>
22- /// Tests for the <see cref="ReactiveObject "/>.
22+ /// Tests for the <see cref="RxObject "/>.
2323/// </summary>
2424public class RxObjectTests
2525{
@@ -43,7 +43,7 @@ public void ChangingShouldAlwaysArriveBeforeChanged()
4343 var beforeSet = "Foo" ;
4444 var afterSet = "Bar" ;
4545
46- var fixture = new TestFixture { IsOnlyOneWord = beforeSet } ;
46+ var fixture = new RxObjectTestFixture { IsOnlyOneWord = beforeSet } ;
4747
4848 var beforeFired = false ;
4949 fixture . Changing . Subscribe (
@@ -79,7 +79,7 @@ public void ChangingShouldAlwaysArriveBeforeChanged()
7979 [ Fact ]
8080 public void DeferredNotificationsDontShowUpUntilUndeferred ( )
8181 {
82- var fixture = new TestFixture ( ) ;
82+ var fixture = new RxObjectTestFixture ( ) ;
8383 fixture . Changing . ToObservableChangeSet ( ImmediateScheduler . Instance ) . Bind ( out var changing ) . Subscribe ( ) ;
8484 fixture . Changed . ToObservableChangeSet ( ImmediateScheduler . Instance ) . Bind ( out var changed ) . Subscribe ( ) ;
8585 var propertyChangingEvents = new List < PropertyChangingEventArgs > ( ) ;
@@ -135,7 +135,7 @@ public void DeferredNotificationsDontShowUpUntilUndeferred()
135135 [ Fact ]
136136 public void ExceptionsThrownInSubscribersShouldMarshalToThrownExceptions ( )
137137 {
138- var fixture = new TestFixture { IsOnlyOneWord = "Foo" } ;
138+ var fixture = new RxObjectTestFixture { IsOnlyOneWord = "Foo" } ;
139139
140140 fixture . Changed . Subscribe ( _ => throw new Exception ( "Terminate!" ) ) ;
141141 fixture . ThrownExceptions . ToObservableChangeSet ( ImmediateScheduler . Instance ) . Bind ( out var exceptionList )
@@ -152,8 +152,8 @@ public void ExceptionsThrownInSubscribersShouldMarshalToThrownExceptions()
152152 [ Fact ]
153153 public void ObservableForPropertyUsingExpression ( )
154154 {
155- var fixture = new TestFixture { IsNotNullString = "Foo" , IsOnlyOneWord = "Baz" } ;
156- var output = new List < IObservedChange < TestFixture , string ? > > ( ) ;
155+ var fixture = new RxObjectTestFixture { IsNotNullString = "Foo" , IsOnlyOneWord = "Baz" } ;
156+ var output = new List < IObservedChange < RxObjectTestFixture , string ? > > ( ) ;
157157 fixture . ObservableForProperty ( x => x . IsNotNullString )
158158 . Subscribe ( x => output . Add ( x ) ) ;
159159
@@ -178,7 +178,7 @@ public void ObservableForPropertyUsingExpression()
178178 [ Fact ]
179179 public void RaiseAndSetUsingExpression ( )
180180 {
181- var fixture = new TestFixture { IsNotNullString = "Foo" , IsOnlyOneWord = "Baz" } ;
181+ var fixture = new RxObjectTestFixture { IsNotNullString = "Foo" , IsOnlyOneWord = "Baz" } ;
182182 var output = new List < string > ( ) ;
183183 fixture . Changed
184184 . Select ( x => x . PropertyName )
@@ -193,10 +193,10 @@ public void RaiseAndSetUsingExpression()
193193 }
194194
195195 /// <summary>
196- /// Test that ReactiveObject shouldn't serialize anything extra.
196+ /// Test that RxObject shouldn't serialize anything extra.
197197 /// </summary>
198198 [ Fact ( Skip = "JSONHelper" ) ]
199- public void ReactiveObjectShouldntSerializeAnythingExtra ( )
199+ public void RxObjectShouldntSerializeAnythingExtra ( )
200200 {
201201 // var fixture = new TestFixture
202202 // {
@@ -225,7 +225,7 @@ public void RxObjectSmokeTest()
225225 {
226226 var outputChanging = new List < string > ( ) ;
227227 var output = new List < string > ( ) ;
228- var fixture = new TestFixture ( ) ;
228+ var fixture = new RxObjectTestFixture ( ) ;
229229
230230 fixture . Changing
231231 . Select ( x => x . PropertyName )
@@ -249,12 +249,12 @@ public void RxObjectSmokeTest()
249249 }
250250
251251 /// <summary>
252- /// Tests to make sure that ReactiveObject doesn't rethrow exceptions.
252+ /// Tests to make sure that RxObject doesn't rethrow exceptions.
253253 /// </summary>
254254 [ Fact ]
255- public void ReactiveObjectShouldRethrowException ( )
255+ public void RxObjectShouldRethrowException ( )
256256 {
257- var fixture = new TestFixture ( ) ;
257+ var fixture = new RxObjectTestFixture ( ) ;
258258 var observable = fixture . WhenAnyValue ( x => x . IsOnlyOneWord ) . Skip ( 1 ) ;
259259 observable . Subscribe ( _ => throw new Exception ( "This is a test." ) ) ;
260260
@@ -268,11 +268,73 @@ public void ReactiveObjectShouldRethrowException()
268268 . Be ( "This is a test." ) ;
269269 }
270270
271+ /// <summary>
272+ /// Tests that change notifications are not delayed.
273+ /// </summary>
274+ [ Fact ]
275+ public void ChangeNotificationsAreNotDelayed ( ) =>
276+
277+ // Given, When, Then
278+ new RxObjectTestFixture ( )
279+ . AreChangeNotificationsDelayed ( )
280+ . Should ( )
281+ . BeFalse ( ) ;
282+
283+ /// <summary>
284+ /// Tests that change notifications are delayed.
285+ /// </summary>
286+ [ Fact ]
287+ public void ChangeNotificationsAreDelayed ( )
288+ {
289+ // Given
290+ var fixture = new RxObjectTestFixture ( ) ;
291+
292+ // When
293+ using var disposable = fixture . DelayChangeNotifications ( ) ;
294+
295+ // Then
296+ fixture
297+ . AreChangeNotificationsDelayed ( )
298+ . Should ( )
299+ . BeTrue ( ) ;
300+ }
301+
302+ /// <summary>
303+ /// Tests that change notifications are enabled.
304+ /// </summary>
305+ [ Fact ]
306+ public void ChangeNotificationsAreEnabled ( ) =>
307+
308+ // Given, When, Then
309+ new RxObjectTestFixture ( )
310+ . AreChangeNotificationsEnabled ( )
311+ . Should ( )
312+ . BeTrue ( ) ;
313+
314+ /// <summary>
315+ /// Tests that change notifications are suppressed.
316+ /// </summary>
317+ [ Fact ]
318+ public void ChangeNotificationsAreSuppressed ( )
319+ {
320+ // Given
321+ var fixture = new RxObjectTestFixture ( ) ;
322+
323+ // When
324+ using var disposable = fixture . SuppressChangeNotifications ( ) ;
325+
326+ // Then
327+ fixture
328+ . AreChangeNotificationsEnabled ( )
329+ . Should ( )
330+ . BeFalse ( ) ;
331+ }
332+
271333 private static void AssertCount ( int expected , params ICollection [ ] collections )
272334 {
273335 foreach ( var collection in collections )
274336 {
275337 Assert . Equal ( expected , collection . Count ) ;
276338 }
277339 }
278- }
340+ }
0 commit comments