PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/MongoDB.Driver.Core.Tests/Core/Misc/RangeTests.cs

http://github.com/mongodb/mongo-csharp-driver
C# | 72 lines | 51 code | 7 blank | 14 comment | 0 complexity | 9a2c2eca2d2296a245f341043a0cb071 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 System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using FluentAssertions;
  21. using MongoDB.Driver.Core.Misc;
  22. using Xunit;
  23. namespace MongoDB.Driver.Core.Misc
  24. {
  25. public class RangeTests
  26. {
  27. [Fact]
  28. public void Constructor_should_throw_when_min_is_greater_than_max()
  29. {
  30. Action act = () => new Range<int>(2, 1);
  31. act.ShouldThrow<ArgumentOutOfRangeException>();
  32. }
  33. [Theory]
  34. [InlineData(0, 0, 0, 0, true)]
  35. [InlineData(0, 1, 0, 1, true)]
  36. [InlineData(0, 0, 0, 0, true)]
  37. [InlineData(0, 1, 0, 0, false)]
  38. [InlineData(0, 0, 0, 1, false)]
  39. public void Equals_should_return_correct_value(int a1, int a2, int b1, int b2, bool expected)
  40. {
  41. var subject = new Range<int>(a1, a2);
  42. var comparand = new Range<int>(b1, b2);
  43. subject.Equals(comparand).Should().Be(expected);
  44. }
  45. [Theory]
  46. [InlineData(0, 0, 0, 0, true)]
  47. [InlineData(0, 1, 0, 0, true)]
  48. [InlineData(0, 1, 0, 0, true)]
  49. [InlineData(0, 1, 1, 1, true)]
  50. [InlineData(0, 0, 0, 1, true)]
  51. [InlineData(1, 1, 0, 1, true)]
  52. [InlineData(0, 2, 1, 1, true)]
  53. [InlineData(0, 2, 2, 3, true)]
  54. [InlineData(0, 2, 3, 3, false)]
  55. [InlineData(0, 2, 3, 4, false)]
  56. [InlineData(3, 3, 0, 2, false)]
  57. [InlineData(3, 4, 0, 2, false)]
  58. public void Overlaps_should_return_correct_value(int a1, int a2, int b1, int b2, bool expected)
  59. {
  60. var subject = new Range<int>(a1, a2);
  61. var comparand = new Range<int>(b1, b2);
  62. subject.Overlaps(comparand).Should().Be(expected);
  63. }
  64. }
  65. }