LetTest.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using System.Reactive.Linq;
  6. using Microsoft.Reactive.Testing;
  7. using Xunit;
  8. namespace ReactiveTests.Tests
  9. {
  10. public class LetTest : ReactiveTest
  11. {
  12. #region Let
  13. [Fact]
  14. public void Let_ArgumentChecking()
  15. {
  16. var someObservable = Observable.Empty<int>();
  17. ReactiveAssert.Throws<ArgumentNullException>(() => ObservableEx.Let(default(IObservable<int>), x => x));
  18. ReactiveAssert.Throws<ArgumentNullException>(() => ObservableEx.Let<int, int>(someObservable, null));
  19. }
  20. [Fact]
  21. public void Let_CallsFunctionImmediately()
  22. {
  23. var called = false;
  24. Observable.Empty<int>().Let(x => { called = true; return x; });
  25. Assert.True(called);
  26. }
  27. #endregion
  28. }
  29. }