Skip to content

Commit b4996f1

Browse files
author
Bernt Røskar Brenna
committed
Endpoint global script objects.
1 parent faa1243 commit b4996f1

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

netmockery/Endpoint.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,11 @@ public EndpointParameter GetParameter(int parameterIndex)
9696

9797
public int ParameterCount => _parameters.Count;
9898

99-
public object GetScriptObject(string name, Func<object> objectCreator)
100-
{
101-
if (!_scriptObjects.ContainsKey(name))
102-
{
103-
_scriptObjects[name] = objectCreator();
104-
}
105-
return _scriptObjects[name];
99+
public object GetScriptObject(string name) => _scriptObjects[name];
106100

107-
}
101+
public bool HasScriptObject(string name) => _scriptObjects.ContainsKey(name);
102+
103+
public void SetScriptObject(string name, object value) => _scriptObjects[name] = value;
108104

109105
public void Add(RequestMatcher requestMatcher, ResponseCreator responseCreator)
110106
{

netmockery/ResponseCreator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ public void SetParam(string name, string value)
111111
}
112112
}
113113

114-
public object GetScriptObject(string name, Func<object> objectCreator) => Endpoint.GetScriptObject(name, objectCreator);
115-
116114
public void SetStaticNow(DateTime now)
117115
{
118116
_now = now;

netmockery/documentation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ Inside a script, the following global variables and functions are available:
160160
* ``GetNow()`` (returns System.DateTime): The current time. See below for why you might want to use ``GetNow()`` inside your scripts instead of using ``System.DateTime.Now``.
161161
* ``GetParam(string paramname)`` (returns string): The value of the specified run-time parameter.
162162

163-
TODO: More scripting documentation.
163+
Source files can be included in scripts using the following syntax:
164+
165+
#include "relativefilen.ame"
164166

165167
### Forwarding requests
166168

0 commit comments

Comments
 (0)