Permalink
Browse files

NCBC-236: Fix view param JSON serialization tests

Change-Id: I6b7ccc1968558afd3b015ec3960f2285dab6714a
Reviewed-on: http://review.couchbase.org/24978
Reviewed-by: Saakshi Manocha <saakshi.manocha@globallogic.com>
Tested-by: Saakshi Manocha <saakshi.manocha@globallogic.com>
  • Loading branch information...
johnzablocki authored and saakshimanocha committed Mar 4, 2013
1 parent 2f76017 commit ffa997551a70c9fc381cf525de4a75b089eaff87
Showing with 13 additions and 8 deletions.
  1. +13 −8 src/Couchbase.Tests/CouchbaseClientViewParameterTests.cs
@@ -5,6 +5,7 @@
using NUnit.Framework;
using Couchbase.Configuration;
using Couchbase.Tests.Mocks;
+using System.Reflection;
namespace Couchbase.Tests
{
@@ -191,12 +192,12 @@ public void When_Requesting_View_Nested_Array_EndKeys_Are_Json_Serialized()
private void testJsonStartKeySerialization(object value, string serializedValue)
{
- testJsonSerialization(value, serializedValue, "startkey");
+ testJsonSerialization(value, serializedValue, "startKey");
}
private void testJsonEndKeySerialization(object value, string serializedValue)
{
- testJsonSerialization(value, serializedValue, "endkey");
+ testJsonSerialization(value, serializedValue, "endKey");
}
private void testJsonKeySerialization(object value, string serializedValue)
@@ -211,21 +212,25 @@ private void testJsonSerialization(object value, string serializedValue, string
switch (paramName)
{
- case "startkey":
+ case "startKey":
view.StartKey(value);
break;
- case "endkey":
+ case "endKey":
view.EndKey(value);
break;
case "key":
view.Key(value);
break;
}
-
- foreach (var item in view) { } //iteration sends request
- var request = GetHttpRequest(clientWithConfig);
- Assert.That(request.Parameters[paramName], Is.EqualTo(serializedValue), "Key was not " + serializedValue);
+ //Previously, params were exposed via a public property on the IHttpRequest,
+ //which was available on the view instance after executing a view.
+ //This is no longer the case and currently, private fields offer the only
+ //means of testing values of view params.
+ var field = view.GetType().GetField(paramName, BindingFlags.NonPublic | BindingFlags.Instance);
+ var val = field.GetValue(view).ToString();
+
+ Assert.That(val, Is.EqualTo(serializedValue), "Key was not " + serializedValue);
}
}

0 comments on commit ffa9975

Please sign in to comment.