ModuleSettingFake.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using Quadarax.Application.QLiberace.Common.Attributes;
  2. using Quadarax.Application.QLiberace.Common.Settings;
  3. namespace Quadarax.Application.QLiberace.Base.Tests.Services.Fakes
  4. {
  5. [Module("test")]
  6. internal class ModuleSettingFake : ModuleSetting, IEquatable<ModuleSettingFake>
  7. {
  8. public const string DefPropertyString1 = "test1";
  9. public const string? DefPropertyString2 = null;
  10. public const string DefPropertyDateTime1String = "12.3.2022 13:02:54";
  11. public const string? DefPropertyDateTime2String = null;
  12. public const string DefPropertyTimeSpanString = "00:00:35";
  13. public const int DefPropertyInt = 35;
  14. public const bool DefPropertyBool = true;
  15. public string PropertyString1 { get; set; }
  16. public string? PropertyString2 { get; set; }
  17. public DateTime PropertyDateTime1 { get; set; }
  18. public DateTime? PropertyDateTime2 { get; set; }
  19. public DateTime? PropertyDateTimeNow { get; set; }
  20. public TimeSpan? PropertyTimeSpan { get; set; }
  21. public int? PropertyInt { get; set; }
  22. public bool PropertyBool { get; set; }
  23. private bool InvisiblePropertyBool { get; set; }
  24. public ModuleSettingFake()
  25. {
  26. PropertyString1 = string.Empty;
  27. PropertyDateTimeNow = DateTime.Now;
  28. Reset();
  29. }
  30. public void Clear()
  31. {
  32. PropertyString1 = string.Empty;
  33. PropertyString2 = null;
  34. PropertyDateTime1 = DateTime.MinValue;
  35. PropertyDateTime2 = null;
  36. PropertyTimeSpan = null;
  37. PropertyInt = null;
  38. PropertyBool = false;
  39. InvisiblePropertyBool = true;
  40. }
  41. public void Reset()
  42. {
  43. PropertyString1 = DefPropertyString1;
  44. PropertyString2 = DefPropertyString2;
  45. PropertyDateTime1 = DateTime.Parse(DefPropertyDateTime1String);
  46. PropertyDateTime2 = string.IsNullOrEmpty(DefPropertyDateTime2String)
  47. ? (DateTime?)null
  48. : DateTime.Parse(DefPropertyDateTime2String!);
  49. PropertyTimeSpan = string.IsNullOrEmpty(DefPropertyTimeSpanString)
  50. ? (TimeSpan?)null
  51. : TimeSpan.Parse(DefPropertyTimeSpanString);
  52. PropertyInt = DefPropertyInt;
  53. PropertyBool = DefPropertyBool;
  54. InvisiblePropertyBool = true;
  55. }
  56. public bool Equals(ModuleSettingFake? other)
  57. {
  58. if (ReferenceEquals(null, other)) return false;
  59. if (ReferenceEquals(this, other)) return true;
  60. return PropertyString1 == other.PropertyString1 && PropertyString2 == other.PropertyString2 && PropertyDateTime1.Equals(other.PropertyDateTime1) && Nullable.Equals(PropertyDateTime2, other.PropertyDateTime2) && Nullable.Equals(PropertyTimeSpan, other.PropertyTimeSpan) && PropertyInt == other.PropertyInt && PropertyBool == other.PropertyBool && InvisiblePropertyBool == other.InvisiblePropertyBool;
  61. }
  62. public override bool Equals(object? obj)
  63. {
  64. if (ReferenceEquals(null, obj)) return false;
  65. if (ReferenceEquals(this, obj)) return true;
  66. if (obj.GetType() != this.GetType()) return false;
  67. return Equals((ModuleSettingFake)obj);
  68. }
  69. public override int GetHashCode()
  70. {
  71. return HashCode.Combine(PropertyString1, PropertyString2, PropertyDateTime1, PropertyDateTime2, PropertyTimeSpan, PropertyInt, PropertyBool, InvisiblePropertyBool);
  72. }
  73. }
  74. }