1
0

ExceptionHelperTest.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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;
  6. using Microsoft.VisualStudio.TestTools.UnitTesting;
  7. using Assert = Xunit.Assert;
  8. namespace ReactiveTests.Tests
  9. {
  10. [TestClass]
  11. public class ExceptionHelperTest
  12. {
  13. private Exception _errors;
  14. [TestMethod]
  15. public void ExceptionHelper_TrySetException_Empty()
  16. {
  17. var ex = new InvalidOperationException();
  18. Assert.True(ExceptionHelper.TrySetException(ref _errors, ex));
  19. Assert.Equal(ex, _errors);
  20. }
  21. [TestMethod]
  22. public void ExceptionHelper_TrySetException_Not_Empty()
  23. {
  24. var ex1 = new InvalidOperationException();
  25. _errors = ex1;
  26. var ex2 = new NotSupportedException();
  27. Assert.False(ExceptionHelper.TrySetException(ref _errors, ex2));
  28. Assert.Equal(ex1, _errors);
  29. }
  30. }
  31. }