Skip to content

Commit 0c2b42d

Browse files
committed
GetNow now.txt documentation
1 parent e50be6d commit 0c2b42d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

netmockery/documentation.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ Command line:
9898
# execute request specified by test N, but display respons (do not check test expectations)
9999
netmockery.exe p:\ath\to\endpoint\directory test --only N --showResponse
100100

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.
109+
101110
<a name="misc"></a>
102111
# Misc
103112

0 commit comments

Comments
 (0)