From 5557b523fdae64e0017cbf5285331f71fe046961 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Feb 2013 01:38:33 +0000 Subject: Add more sub-tests to TestJsonSetValue for paths containing []{} without {} delineation. As expected, values are not set and the set call returns FALSE (0). As a reminder, these tests are not currently running on jenkins continuous integration as the functionality is only available on .net 4 (mono 2.8 and later). --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 91 ++++++++++++++++++++-- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 71983b3..f25f290 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -415,7 +415,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } // Commented out as this currently unexpectedly fails. - // Test setting a key containing periods. + // Test setting a key containing periods with delineation // { // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); // @@ -426,7 +426,64 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // Assert.That(value, Is.EqualTo("Times")); // } - // Test setting a key containing empty brackets + // *** Test [] *** + + // Test setting a key containing unbalanced ] without delineation. Expecting failure + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun]Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun]Circus"); + Assert.That(value, Is.EqualTo("")); + } + + // Test setting a key containing unbalanced [ without delineation. Expecting failure + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun[Circus"); + Assert.That(value, Is.EqualTo("")); + } + + // Test setting a key containing unbalanced [] without delineation. Expecting failure + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[]Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun[]Circus"); + Assert.That(value, Is.EqualTo("")); + } + + // Test setting a key containing unbalanced ] with delineation + { + 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 [ with delineation + { + 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 balanced [] with delineation { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); @@ -438,7 +495,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } // Commented out as this currently unexpectedly fails. -// // Test setting a key containing brackets with an integer +// // Test setting a key containing brackets around an integer with delineation // { // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); // @@ -449,6 +506,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // Assert.That(value, Is.EqualTo("Times")); // } + // *** Test {} *** + + // Test setting a key containing unbalanced } without delineation. Expecting failure (?) + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun}Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun}Circus"); + Assert.That(value, Is.EqualTo("")); + } + + // Test setting a key containing unbalanced { without delineation. Expecting failure (?) + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun{Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun}Circus"); + Assert.That(value, Is.EqualTo("")); + } + // Commented out as this currently unexpectedly fails. // // Test setting a key containing unbalanced } // { @@ -461,7 +542,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // Assert.That(value, Is.EqualTo("Times")); // } - // Test setting a key containing unbalanced { + // Test setting a key containing unbalanced { with delineation { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); @@ -472,7 +553,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("Times")); } - // Test setting a key containing balanced {}. This should fail. + // Test setting a key containing balanced {} with delineation. This should fail. { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); -- cgit v1.1