You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: netmockery/documentation.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,15 @@ Command line:
98
98
# execute request specified by test N, but display respons (do not check test expectations)
99
99
netmockery.exe p:\ath\to\endpoint\directory test --only N --showResponse
100
100
101
+
## Handling time when testing
102
+
103
+
* If you have scripts that need the current date/time, do not use ``System.DateTime.Now``.
104
+
* Instead, use the ``GetNow()`` function inside your scripts.
105
+
* When netmockery is running serving requests in the normal case, ``GetNow()`` returns ``System.DateTime.Now``.
106
+
* But when running tests, ``GetNow()`` will return the timestamp specified in the special file ``tests\now.txt``. This file should contain a single line with the time stamp
107
+
in ``yyyy-MM-dd HH:mm:ss`` format.
108
+
* Using ``GetNow()`` / ``now.txt`` you can create stable test cases, even if your scripted service simulators return dynamic data based on current time.
0 commit comments