PageRenderTime 56ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/Passive.Test/Utility/ShouldExtensions.cs

https://github.com/Talljoe/Passive
C# | 28 lines | 24 code | 2 blank | 2 comment | 0 complexity | db1a32a9f9d6b171916bd2e21a3e710e MD5 | raw file
  1. // Copyright (c) 2011 Tall Ambitions, LLC
  2. // See included LICENSE for details.
  3. namespace Passive.Test.Utility
  4. {
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using FluentAssertions;
  8. using FluentAssertions.Assertions;
  9. public static class ShouldExtensions
  10. {
  11. public static AndConstraint<GenericCollectionAssertions<T>> BeEmptyOrSubsetOf<T>(
  12. this GenericCollectionAssertions<T> source, IEnumerable<T> expected, string reason = null, params object[] reasonArgs)
  13. {
  14. return source.Subject.Any()
  15. ? source.BeSubsetOf(expected, reason, reasonArgs)
  16. : source.BeEmpty(reason, reasonArgs);
  17. }
  18. public static AndConstraint<GenericCollectionAssertions<T>> HaveEquivalencyTo<T>(
  19. this GenericCollectionAssertions<T> source, IEnumerable<T> expected, string reason = null, params object[] reasonArgs)
  20. {
  21. return expected.Any()
  22. ? source.BeEquivalentTo(expected, reason, reasonArgs)
  23. : source.BeEmpty(reason, reasonArgs);
  24. }
  25. }
  26. }