Add TestJsonWriteReadNotecard() regression test

0.7.4-extended
Justin Clark-Casey (justincc) 2013-02-07 02:19:26 +00:00
parent fb2de29f77
commit 365292e38f
2 changed files with 45 additions and 2 deletions

View File

@ -101,7 +101,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
private object InvokeOp(string name, params object[] args)
{
return m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, name, args);
return InvokeOpOnHost(name, UUID.Zero, args);
}
private object InvokeOpOnHost(string name, UUID hostId, params object[] args)
{
return m_smcm.InvokeOperation(hostId, UUID.Zero, name, args);
}
[Test]
@ -209,6 +214,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
Assert.That(value, Is.EqualTo("World"));
}
/// <summary>
/// Test for reading and writing json to a notecard
/// </summary>
/// <remarks>
/// TODO: Really needs to test correct receipt of the link_message event. Could do this by directly fetching
/// it via the MockScriptEngine or perhaps by a dummy script instance.
/// </remarks>
[Test]
public void TestJsonWriteReadNotecard()
{
TestHelpers.InMethod();
TestHelpers.EnableLogging();
string notecardName = "nc1";
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1));
m_scene.AddSceneObject(so);
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }");
// Write notecard
UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName);
Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName);
Assert.That(nc1Item, Is.Not.Null);
// TODO: Should probably independently check the contents.
// Read notecard
UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }");
UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName);
Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
string value = (string)InvokeOp("JsonGetValue", storeId, "Hello");
Assert.That(value, Is.EqualTo("World"));
}
public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; }
}
}

View File

@ -85,7 +85,7 @@ namespace OpenSim.Tests.Common
public bool PostScriptEvent(UUID itemID, string name, object[] args)
{
throw new System.NotImplementedException ();
return false;
}
public bool PostObjectEvent(UUID itemID, string name, object[] args)