AssertHelper.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. public static class AssertHelper
  6. {
  7. [Conditional("UNITY_ASSERTIONS")]
  8. public static void Implies(bool condition, bool result, string message = "")
  9. {
  10. if (condition)
  11. {
  12. }
  13. }
  14. [Conditional("UNITY_ASSERTIONS")]
  15. public static void Implies(bool condition, Func<bool> result, string message = "")
  16. {
  17. if (condition)
  18. {
  19. }
  20. }
  21. [Conditional("UNITY_ASSERTIONS")]
  22. public static void Implies(string conditionName, bool condition, string resultName, bool result)
  23. {
  24. }
  25. [Conditional("UNITY_ASSERTIONS")]
  26. public static void Implies(string conditionName, bool condition, string resultName, Func<bool> result)
  27. {
  28. if (condition)
  29. {
  30. }
  31. }
  32. [Conditional("UNITY_ASSERTIONS")]
  33. public static void Contains<T>(T value, IEnumerable<T> collection, string message = "")
  34. {
  35. if (!collection.Contains(value))
  36. {
  37. string str = "The value " + value + " was not found in the collection [";
  38. bool flag = true;
  39. foreach (T t in collection)
  40. {
  41. if (!flag)
  42. {
  43. str += ", ";
  44. flag = false;
  45. }
  46. str += t.ToString();
  47. }
  48. str = str + "]\n" + message;
  49. }
  50. }
  51. }