diff options
Diffstat (limited to 'OpenSim/Tests/Common/Mock')
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockScriptEngine.cs | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs index 78bab5b..6a53fe7 100644 --- a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs +++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs | |||
@@ -40,10 +40,33 @@ namespace OpenSim.Tests.Common | |||
40 | { | 40 | { |
41 | public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine | 41 | public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine |
42 | { | 42 | { |
43 | public IConfigSource ConfigSource { get; private set; } | ||
44 | |||
45 | public IConfig Config { get; private set; } | ||
46 | |||
43 | private Scene m_scene; | 47 | private Scene m_scene; |
44 | 48 | ||
49 | /// <summary> | ||
50 | /// Expose posted events to tests. | ||
51 | /// </summary> | ||
52 | public Dictionary<UUID, List<EventParams>> PostedEvents { get; private set; } | ||
53 | |||
54 | /// <summary> | ||
55 | /// A very primitive way of hooking text cose to a posed event. | ||
56 | /// </summary> | ||
57 | /// <remarks> | ||
58 | /// May be replaced with something that uses more original code in the future. | ||
59 | /// </remarks> | ||
60 | public event Action<UUID, EventParams> PostEventHook; | ||
61 | |||
45 | public void Initialise(IConfigSource source) | 62 | public void Initialise(IConfigSource source) |
46 | { | 63 | { |
64 | ConfigSource = source; | ||
65 | |||
66 | // Can set later on if required | ||
67 | Config = new IniConfig("MockScriptEngine", ConfigSource); | ||
68 | |||
69 | PostedEvents = new Dictionary<UUID, List<EventParams>>(); | ||
47 | } | 70 | } |
48 | 71 | ||
49 | public void Close() | 72 | public void Close() |
@@ -85,7 +108,28 @@ namespace OpenSim.Tests.Common | |||
85 | 108 | ||
86 | public bool PostScriptEvent(UUID itemID, string name, object[] args) | 109 | public bool PostScriptEvent(UUID itemID, string name, object[] args) |
87 | { | 110 | { |
88 | return false; | 111 | // Console.WriteLine("Posting event {0} for {1}", name, itemID); |
112 | |||
113 | EventParams evParams = new EventParams(name, args, null); | ||
114 | |||
115 | List<EventParams> eventsForItem; | ||
116 | |||
117 | if (!PostedEvents.ContainsKey(itemID)) | ||
118 | { | ||
119 | eventsForItem = new List<EventParams>(); | ||
120 | PostedEvents.Add(itemID, eventsForItem); | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | eventsForItem = PostedEvents[itemID]; | ||
125 | } | ||
126 | |||
127 | eventsForItem.Add(evParams); | ||
128 | |||
129 | if (PostEventHook != null) | ||
130 | PostEventHook(itemID, evParams); | ||
131 | |||
132 | return true; | ||
89 | } | 133 | } |
90 | 134 | ||
91 | public bool PostObjectEvent(UUID itemID, string name, object[] args) | 135 | public bool PostObjectEvent(UUID itemID, string name, object[] args) |
@@ -195,11 +239,7 @@ namespace OpenSim.Tests.Common | |||
195 | 239 | ||
196 | public Scene World { get { return m_scene; } } | 240 | public Scene World { get { return m_scene; } } |
197 | 241 | ||
198 | public IScriptModule ScriptModule { get { throw new System.NotImplementedException(); } } | 242 | public IScriptModule ScriptModule { get { return this; } } |
199 | |||
200 | public IConfig Config { get { throw new System.NotImplementedException (); } } | ||
201 | |||
202 | public IConfigSource ConfigSource { get { throw new System.NotImplementedException (); } } | ||
203 | 243 | ||
204 | public string ScriptEnginePath { get { throw new System.NotImplementedException (); }} | 244 | public string ScriptEnginePath { get { throw new System.NotImplementedException (); }} |
205 | 245 | ||
@@ -210,5 +250,10 @@ namespace OpenSim.Tests.Common | |||
210 | public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } } | 250 | public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } } |
211 | 251 | ||
212 | public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } } | 252 | public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } } |
253 | |||
254 | public void ClearPostedEvents() | ||
255 | { | ||
256 | PostedEvents.Clear(); | ||
257 | } | ||
213 | } | 258 | } |
214 | } \ No newline at end of file | 259 | } \ No newline at end of file |