PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/MongoDB.Driver.Core.Tests/Core/Servers/HeartbeatDelayTests.cs

http://github.com/mongodb/mongo-csharp-driver
C# | 51 lines | 29 code | 8 blank | 14 comment | 0 complexity | 088277b1dbec4e604e4f07a63adb1a4d MD5 | raw file
Possible License(s): Apache-2.0
  1. /* Copyright 2013-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using FluentAssertions;
  17. using Xunit;
  18. namespace MongoDB.Driver.Core.Servers
  19. {
  20. public class HeartbeatDelayTests
  21. {
  22. [Fact]
  23. public void Dispose_can_be_called_multiple_times()
  24. {
  25. var subject = new HeartbeatDelay(TimeSpan.FromHours(10), TimeSpan.FromMilliseconds(1));
  26. subject.Dispose();
  27. subject.Dispose();
  28. }
  29. [Fact]
  30. public void Task_should_complete_when_heartbeatInterval_has_expired()
  31. {
  32. var subject = new HeartbeatDelay(TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(1));
  33. subject.Task.Wait(TimeSpan.FromSeconds(1)).Should().BeTrue();
  34. }
  35. [Fact]
  36. public void Task_should_complete_when_early_heartbeat_is_requested()
  37. {
  38. var subject = new HeartbeatDelay(TimeSpan.FromHours(10), TimeSpan.FromMilliseconds(1));
  39. subject.RequestHeartbeat();
  40. subject.Task.Wait(TimeSpan.FromSeconds(1)).Should().BeTrue();
  41. }
  42. }
  43. }