Fakes.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //#define USE_FAKES
  2. // This file represent mock for System.DateTime & System.Guid (because Microsoft Fakes doesn't correct work in .Net Core)
  3. using System.Runtime.CompilerServices;
  4. namespace SystemFake
  5. {
  6. internal struct DateTime
  7. {
  8. internal static System.DateTime Now
  9. {
  10. #if NETSTANDARD || NETCOREAPP
  11. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  12. #endif
  13. get
  14. {
  15. #if !USE_FAKES
  16. return System.DateTime.Now;
  17. #else
  18. return new System.DateTime(0, System.DateTimeKind.Utc);
  19. #endif
  20. }
  21. }
  22. internal static System.DateTime UtcNow
  23. {
  24. #if NETSTANDARD || NETCOREAPP
  25. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  26. #endif
  27. get
  28. {
  29. #if !USE_FAKES
  30. return System.DateTime.UtcNow;
  31. #else
  32. return new System.DateTime(0, System.DateTimeKind.Utc);
  33. #endif
  34. }
  35. }
  36. }
  37. internal struct Guid
  38. {
  39. #if NETSTANDARD || NETCOREAPP
  40. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  41. #endif
  42. internal static System.Guid NewGuid()
  43. {
  44. #if !USE_FAKES
  45. return System.Guid.NewGuid();
  46. #else
  47. return System.Guid.Empty;
  48. #endif
  49. }
  50. }
  51. }