WindowsFormsExtensionsNewPackageAnalyzerTests.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. namespace System.Reactive.Analyzers.Test
  5. {
  6. [TestClass]
  7. public sealed class WindowsFormsExtensionsNewPackageAnalyzerTests : TestExtensionMethodAnalyzerBase
  8. {
  9. [TestMethod]
  10. public async Task DetectIObservableSubscribeOnControl()
  11. {
  12. await TestExtensionMethodOnIObservable(
  13. "System.Windows.Forms.Control",
  14. "SubscribeOn",
  15. "RXNET0001");
  16. }
  17. /// <summary>
  18. /// Check that we handle SubscribeOn for types that derive from Control (and not just Control itself).
  19. /// </summary>
  20. /// <returns></returns>
  21. [TestMethod]
  22. public async Task DetectIObservableSubscribeOnButton()
  23. {
  24. await TestExtensionMethodOnIObservable(
  25. "System.Windows.Forms.Button",
  26. "SubscribeOn",
  27. "RXNET0001");
  28. }
  29. [TestMethod]
  30. public async Task DetectIObservableObserveOnControl()
  31. {
  32. await TestExtensionMethodOnIObservable(
  33. "System.Windows.Forms.Control",
  34. "ObserveOn",
  35. "RXNET0001");
  36. }
  37. /// <summary>
  38. /// Check that we handle ObserveOn for types that derive from Control (and not just Control itself).
  39. /// </summary>
  40. /// <returns></returns>
  41. [TestMethod]
  42. public async Task DetectIObservableObserveOnButton()
  43. {
  44. await TestExtensionMethodOnIObservable(
  45. "System.Windows.Forms.Button",
  46. "ObserveOn",
  47. "RXNET0001");
  48. }
  49. [TestMethod]
  50. public async Task DetectConcreteObservableSubscribeOnControl()
  51. {
  52. await TestExtensionMethodOnSubject(
  53. "System.Windows.Forms.Control",
  54. "SubscribeOn",
  55. "RXNET0001");
  56. }
  57. [TestMethod]
  58. public async Task DetectConcreteObservableObserveOnControl()
  59. {
  60. await TestExtensionMethodOnSubject(
  61. "System.Windows.Forms.Control",
  62. "ObserveOn",
  63. "RXNET0001");
  64. }
  65. [TestMethod]
  66. public async Task DetectConcreteObservableObserveOnButton()
  67. {
  68. await TestExtensionMethodOnSubject(
  69. "System.Windows.Forms.Button",
  70. "ObserveOn",
  71. "RXNET0001");
  72. }
  73. }
  74. }