LetTest.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT 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 Microsoft.VisualStudio.TestTools.UnitTesting;
  8. using Assert = Xunit.Assert;
  9. namespace ReactiveTests.Tests
  10. {
  11. [TestClass]
  12. public class LetTest : ReactiveTest
  13. {
  14. #region Let
  15. [TestMethod]
  16. public void Let_ArgumentChecking()
  17. {
  18. var someObservable = Observable.Empty<int>();
  19. ReactiveAssert.Throws<ArgumentNullException>(() => ObservableEx.Let(default(IObservable<int>), x => x));
  20. ReactiveAssert.Throws<ArgumentNullException>(() => ObservableEx.Let<int, int>(someObservable, null));
  21. }
  22. [TestMethod]
  23. public void Let_CallsFunctionImmediately()
  24. {
  25. var called = false;
  26. Observable.Empty<int>().Let(x => { called = true; return x; });
  27. Assert.True(called);
  28. }
  29. #endregion
  30. }
  31. }