PageRenderTime 283ms CodeModel.GetById 28ms RepoModel.GetById 8ms app.codeStats 0ms

/src/MongoDB.Bson.TestHelpers/EqualityComparers/GenericCollectionAssertionsExtensions.cs

http://github.com/mongodb/mongo-csharp-driver
C# | 43 lines | 24 code | 4 blank | 15 comment | 0 complexity | 6299ee35a2843631cbc3700494d8c9b7 MD5 | raw file
Possible License(s): Apache-2.0
  1. /* Copyright 2010-2014 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 FluentAssertions;
  18. using FluentAssertions.Collections;
  19. namespace MongoDB.Bson.TestHelpers.EqualityComparers
  20. {
  21. public static class GenericCollectionAssertionsExtensions
  22. {
  23. // static methods
  24. public static AndConstraint<GenericCollectionAssertions<T>> EqualUsing<T>(
  25. this GenericCollectionAssertions<T> assertions, IEnumerable<T> expectation, IEqualityComparer<T> comparer, string because = "", params object[] reasonArgs)
  26. {
  27. Func<T, T, bool> predicate = (x, y) =>
  28. {
  29. return comparer.Equals(x, y);
  30. };
  31. return assertions.Equal(expectation, predicate, because, reasonArgs);
  32. }
  33. public static AndConstraint<GenericCollectionAssertions<T>> EqualUsing<T>(
  34. this GenericCollectionAssertions<T> assertions, IEnumerable<T> expectation, IEqualityComparerSource source, string because = "", params object[] reasonArgs)
  35. {
  36. return assertions.EqualUsing(expectation, source.GetComparer<T>(), because, reasonArgs);
  37. }
  38. }
  39. }