From b1a165a39ad5aef2b55e367aa7ff984374016ba7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Feb 2013 01:25:30 +0000 Subject: Extend JsonTestSetValue() with tests for escaping brackets, periods and unbalanced braces from paths The sub-tests that are commented out are currently those which fail unexpectedly based on my understanding of the path syntax --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 73 +++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 9721b8d..71983b3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -405,7 +405,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // TestHelpers.EnableLogging(); { - UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); int result = (int)InvokeOp("JsonSetValue", storeId, "Fun", "Times"); Assert.That(result, Is.EqualTo(1)); @@ -414,9 +414,78 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("Times")); } + // Commented out as this currently unexpectedly fails. + // Test setting a key containing periods. +// { +// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); +// +// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times"); +// Assert.That(result, Is.EqualTo(1)); +// +// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}"); +// Assert.That(value, Is.EqualTo("Times")); +// } + + // Test setting a key containing empty brackets + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[]Circus}", "Times"); + Assert.That(result, Is.EqualTo(1)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[]Circus}"); + Assert.That(value, Is.EqualTo("Times")); + } + + // Commented out as this currently unexpectedly fails. +// // Test setting a key containing brackets with an integer +// { +// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); +// +// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times"); +// Assert.That(result, Is.EqualTo(1)); +// +// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[]Circus}"); +// Assert.That(value, Is.EqualTo("Times")); +// } + + // Commented out as this currently unexpectedly fails. +// // Test setting a key containing unbalanced } +// { +// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); +// +// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times"); +// Assert.That(result, Is.EqualTo(1)); +// +// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun}Circus}"); +// Assert.That(value, Is.EqualTo("Times")); +// } + + // Test setting a key containing unbalanced { + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Circus}", "Times"); + Assert.That(result, Is.EqualTo(1)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun{Circus}"); + Assert.That(value, Is.EqualTo("Times")); + } + + // Test setting a key containing balanced {}. This should fail. + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Filled}Circus}", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun{Filled}Circus}"); + Assert.That(value, Is.EqualTo("")); + } + // Test setting to location that does not exist. This should fail. { - UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); int result = (int)InvokeOp("JsonSetValue", storeId, "Fun.Circus", "Times"); Assert.That(result, Is.EqualTo(0)); -- cgit v1.1