MockDisposable.cs 949 B

12345678910111213141516171819202122232425262728
  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.Collections.Generic;
  6. using Microsoft.Reactive.Testing;
  7. namespace ReactiveTests
  8. {
  9. #pragma warning disable CA1816 // (Overridable IDisposable.) This is a specialized base type, and it would be inappropriate to encourage anyone to build derived types that do more in Dispose.
  10. public class MockDisposable : List<long>, IDisposable
  11. {
  12. private readonly TestScheduler _scheduler;
  13. public MockDisposable(TestScheduler scheduler)
  14. {
  15. _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
  16. Add(scheduler.Clock);
  17. }
  18. public void Dispose()
  19. {
  20. Add(_scheduler.Clock);
  21. }
  22. }
  23. #pragma warning restore CA1816
  24. }