PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterIdTests.cs

http://github.com/mongodb/mongo-csharp-driver
C# | 60 lines | 40 code | 6 blank | 14 comment | 0 complexity | 948e5bce64ea4ff43664f46a18d3484a 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 MongoDB.Driver.Core.Clusters;
  17. using FluentAssertions;
  18. using Xunit;
  19. namespace MongoDB.Driver.Core.Clusters
  20. {
  21. public class ClusterIdTests
  22. {
  23. [Fact]
  24. public void Constructor_should_initialize_instance()
  25. {
  26. var subject = new ClusterId(1);
  27. subject.Value.Should().Be(1);
  28. }
  29. [Fact]
  30. public void Equals_should_return_false_if_any_field_is_not_equal()
  31. {
  32. var subject1 = new ClusterId(1);
  33. var subject2 = new ClusterId(2);
  34. subject1.Equals(subject2).Should().BeFalse();
  35. subject1.Equals((object)subject2).Should().BeFalse();
  36. subject1.GetHashCode().Should().NotBe(subject2.GetHashCode());
  37. }
  38. [Fact]
  39. public void Equals_should_return_true_if_all_fiels_are_equal()
  40. {
  41. var subject1 = new ClusterId(1);
  42. var subject2 = new ClusterId(1);
  43. subject1.Equals(subject2).Should().BeTrue();
  44. subject1.Equals((object)subject2).Should().BeTrue();
  45. subject1.GetHashCode().Should().Be(subject2.GetHashCode());
  46. }
  47. [Fact]
  48. public void ToString_should_return_string_representation()
  49. {
  50. var subject = new ClusterId(1);
  51. subject.ToString().Should().Be("1");
  52. }
  53. }
  54. }