private static object[] ExtractCallArguments(WampMessage <MockRaw> wampMessage) { MockRaw callId = wampMessage.Arguments[0]; MockRaw procUri = wampMessage.Arguments[1]; object[] arguments = wampMessage.Arguments.Skip(2) .Select(x => x.Value).ToArray(); return(new object[] { callId.Value, procUri.Value, arguments }); }
public MockRaw(object value) { MockRaw raw = value as MockRaw; object[] rawArray = value as object[]; if (raw != null) { mValue = Clone(raw.Value); } else if (rawArray != null && rawArray.GetType() == typeof(object[])) { mValue = ConvertToMockRawArray(rawArray); } else { mValue = Clone(value); } }
private static CallErrorDetails GetErrorDetails(MockRaw[] arguments) { object errorDetails = null; if (arguments.Length >= 4) { errorDetails = arguments[3].Value; } return new CallErrorDetails((string)arguments[1].Value, (string)arguments[2].Value, errorDetails); }
static Responses() { mRpccall0 = new WampMessage<MockRaw>(); { mRpccall0.MessageType = WampMessageType.v1Welcome; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("hT8vUg9h_9qh9rcd"); arguments[1] = new MockRaw(1); arguments[2] = new MockRaw("Autobahn/0.5.14"); mRpccall0.Arguments = arguments; } mRpccall1 = new WampMessage<MockRaw>(); { mRpccall1.MessageType = WampMessageType.v1CallResult; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("0.gmf103gm25efjemi"); arguments[1] = new MockRaw(529); mRpccall1.Arguments = arguments; } mRpccall2 = new WampMessage<MockRaw>(); { mRpccall2.MessageType = WampMessageType.v1CallResult; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("0.2qpscjivpf58w7b9"); arguments[1] = new MockRaw(30); mRpccall2.Arguments = arguments; } mRpccall3 = new WampMessage<MockRaw>(); { mRpccall3.MessageType = WampMessageType.v1CallResult; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("0.407ldfwznk10dx6r"); arguments[1] = new MockRaw(15); mRpccall3.Arguments = arguments; } mRpccall4 = new WampMessage<MockRaw>(); { mRpccall4.MessageType = WampMessageType.v1CallResult; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("0.d9bcva2fszjpds4i"); arguments[1] = new MockRaw(529); mRpccall4.Arguments = arguments; } mRpccall5 = new WampMessage<MockRaw>(); { mRpccall5.MessageType = WampMessageType.v1CallError; MockRaw[] arguments = new MockRaw[4]; arguments[0] = new MockRaw("0.h1r0hxik62a3v7vi"); arguments[1] = new MockRaw("http://api.wamp.ws/error#generic"); arguments[2] = new MockRaw("math domain error"); arguments[3] = new MockRaw(new [] { @"Traceback (most recent call last):", @" File ""C:\Python27\lib\site-packages\autobahn-0.5.14-py2.7.egg\autobahn\websocket.py"", line 1674, in processDataHybi" , @" fr = self.onFrameEnd()", @" File ""C:\Python27\lib\site-packages\autobahn-0.5.14-py2.7.egg\autobahn\websocket.py"", line 1751, in onFrameEnd" , @" self.onMessageEnd()", @" File ""C:\Python27\lib\site-packages\autobahn-0.5.14-py2.7.egg\autobahn\websocket.py"", line 649, in onMessageEnd" , @" self.onMessage(payload, self.message_opcode == WebSocketProtocol.MESSAGE_TYPE_BINARY)" , @" File ""C:\Python27\lib\site-packages\autobahn-0.5.14-py2.7.egg\autobahn\wamp.py"", line 877, in onMessage" , @" d = maybeDeferred(self._callProcedure, call)", @"--- <exception caught here> ---", @" File ""C:\Python27\lib\site-packages\twisted\internet\defer.py"", line 137, in maybeDeferred" , @" result = f(*args, **kw)", @" File ""C:\Python27\lib\site-packages\autobahn-0.5.14-py2.7.egg\autobahn\wamp.py"", line 633, in _callProcedure" , @" return m[1](m[0], *cargs)", @" File ""C:\Python27\lib\site-packages\autobahntestsuite\wamptestserver.py"", line 76, in sqrt" , @" return math.sqrt(x)", @"exceptions.ValueError: math domain error", }); mRpccall5.Arguments = arguments; } mRpccall6 = new WampMessage<MockRaw>(); { mRpccall6.MessageType = WampMessageType.v1CallError; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.bbmk6lzxl6vibe29"); arguments[1] = new MockRaw("http://example.com/error#number_too_big"); arguments[2] = new MockRaw("number 1001 too big to square"); mRpccall6.Arguments = arguments; } mRpccall7 = new WampMessage<MockRaw>(); { mRpccall7.MessageType = WampMessageType.v1CallResult; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("0.nzdto9xdn6vl5wmi"); arguments[1] = new MockRaw(15); mRpccall7.Arguments = arguments; } mRpccall8 = new WampMessage<MockRaw>(); { mRpccall8.MessageType = WampMessageType.v1CallError; MockRaw[] arguments = new MockRaw[4]; arguments[0] = new MockRaw("0.tuoo16bh5pix80k9"); arguments[1] = new MockRaw("http://example.com/error#invalid_numbers"); arguments[2] = new MockRaw("one or more numbers are multiples of 3"); arguments[3] = new MockRaw(new [] { 0, 3, }); mRpccall8.Arguments = arguments; } mRpccall9 = new WampMessage<MockRaw>(); { mRpccall9.MessageType = WampMessageType.v1CallResult; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("0.8ddkhnsgjwtgldi"); arguments[1] = new MockRaw(6); mRpccall9.Arguments = arguments; } }
static Requests() { mRpccall0 = new WampMessage<MockRaw>(); { mRpccall0.MessageType = WampMessageType.v1Prefix; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("calc"); arguments[1] = new MockRaw("http://example.com/simple/calc#"); mRpccall0.Arguments = arguments; } mRpccall1 = new WampMessage<MockRaw>(); { mRpccall1.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.gmf103gm25efjemi"); arguments[1] = new MockRaw("calc:square"); arguments[2] = new MockRaw(23); mRpccall1.Arguments = arguments; } mRpccall2 = new WampMessage<MockRaw>(); { mRpccall2.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[4]; arguments[0] = new MockRaw("0.2qpscjivpf58w7b9"); arguments[1] = new MockRaw("calc:add"); arguments[2] = new MockRaw(23); arguments[3] = new MockRaw(7); mRpccall2.Arguments = arguments; } mRpccall3 = new WampMessage<MockRaw>(); { mRpccall3.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.407ldfwznk10dx6r"); arguments[1] = new MockRaw("calc:sum"); arguments[2] = new MockRaw(new [] { 1, 2, 3, 4, 5, }); mRpccall3.Arguments = arguments; } mRpccall4 = new WampMessage<MockRaw>(); { mRpccall4.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.d9bcva2fszjpds4i"); arguments[1] = new MockRaw("calc:square"); arguments[2] = new MockRaw(23); mRpccall4.Arguments = arguments; } mRpccall5 = new WampMessage<MockRaw>(); { mRpccall5.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.h1r0hxik62a3v7vi"); arguments[1] = new MockRaw("calc:sqrt"); arguments[2] = new MockRaw(-1); mRpccall5.Arguments = arguments; } mRpccall6 = new WampMessage<MockRaw>(); { mRpccall6.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.bbmk6lzxl6vibe29"); arguments[1] = new MockRaw("calc:square"); arguments[2] = new MockRaw(1001); mRpccall6.Arguments = arguments; } mRpccall7 = new WampMessage<MockRaw>(); { mRpccall7.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.8ddkhnsgjwtgldi"); arguments[1] = new MockRaw("calc:asum"); arguments[2] = new MockRaw(new [] { 1, 2, 3, }); mRpccall7.Arguments = arguments; } mRpccall8 = new WampMessage<MockRaw>(); { mRpccall8.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.nzdto9xdn6vl5wmi"); arguments[1] = new MockRaw("calc:sum"); arguments[2] = new MockRaw(new [] { 4, 5, 6, }); mRpccall8.Arguments = arguments; } mRpccall9 = new WampMessage<MockRaw>(); { mRpccall9.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("0.tuoo16bh5pix80k9"); arguments[1] = new MockRaw("calc:pickySum"); arguments[2] = new MockRaw(new [] { 0, 1, 2, 3, 4, 5, }); mRpccall9.Arguments = arguments; } }
private static WampRpcCall GetRpcCall(MockRaw[] arguments) { string callId = (string) arguments[0].Value; string procUri = (string) arguments[1].Value; object[] methodArguments = arguments.Skip(2).Select(x => x.Value).ToArray(); return new WampRpcCall() { Arguments = methodArguments, ProcUri = procUri, ReturnType = typeof (object) // Not sure how we'll do it. }; }
static Messages() { mPrefixMessage2 = new WampMessage <MockRaw>(); { mPrefixMessage2.MessageType = WampMessageType.v1Prefix; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("keyvalue"); arguments[1] = new MockRaw("http://example.com/simple/keyvalue#"); mPrefixMessage2.Arguments = arguments; } mPrefixMessage1 = new WampMessage <MockRaw>(); { mPrefixMessage1.MessageType = WampMessageType.v1Prefix; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("calc"); arguments[1] = new MockRaw("http://example.com/simple/calc#"); mPrefixMessage1.Arguments = arguments; } mCallMessageForRpcWith2ArgumentsUsingCurie = new WampMessage <MockRaw>(); { mCallMessageForRpcWith2ArgumentsUsingCurie.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[4]; arguments[0] = new MockRaw("Yp9EFZt9DFkuKndg"); arguments[1] = new MockRaw("api:add2"); arguments[2] = new MockRaw(23); arguments[3] = new MockRaw(99); mCallMessageForRpcWith2ArgumentsUsingCurie.Arguments = arguments; } mCallMessageForRpcWith1ArgumentValueBeingNull = new WampMessage <MockRaw>(); { mCallMessageForRpcWith1ArgumentValueBeingNull.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("Dns3wuQo0ipOX1Xc"); arguments[1] = new MockRaw("http://example.com/api#woooat"); arguments[2] = new MockRaw(null); mCallMessageForRpcWith1ArgumentValueBeingNull.Arguments = arguments; } mCallMessageForRpcWith1ArgumentValueBeingAListOfIntegersUsingCurie = new WampMessage <MockRaw>(); { mCallMessageForRpcWith1ArgumentValueBeingAListOfIntegersUsingCurie.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("M0nncaH0ywCSYzRv"); arguments[1] = new MockRaw("api:sum"); arguments[2] = new MockRaw(new[] { 9, 1, 3, 4, }); mCallMessageForRpcWith1ArgumentValueBeingAListOfIntegersUsingCurie.Arguments = arguments; } mCallMessageForRpcWith2ComplexArgumentsUsingCurie = new WampMessage <MockRaw>(); { mCallMessageForRpcWith2ComplexArgumentsUsingCurie.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[4]; arguments[0] = new MockRaw("ujL7WKGXCn8bkvFV"); arguments[1] = new MockRaw("keyvalue:set"); arguments[2] = new MockRaw("foobar"); arguments[3] = new MockRaw(new { value1 = 23, value2 = "singsing", value3 = true, modified = new DateTime(2012, 3, 29, 10, 29, 16, 625), }); mCallMessageForRpcWith2ComplexArgumentsUsingCurie.Arguments = arguments; } mCallMessageForRpcWith1ComplexObjectArgument = new WampMessage <MockRaw>(); { mCallMessageForRpcWith1ComplexObjectArgument.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("J5DkZJgByutvaDWc"); arguments[1] = new MockRaw("http://example.com/api#storeMeal"); arguments[2] = new MockRaw(new { category = "dinner", calories = 2309, }); mCallMessageForRpcWith1ComplexObjectArgument.Arguments = arguments; } mCallMessageForRpcWithNoArguments = new WampMessage <MockRaw>(); { mCallMessageForRpcWithNoArguments.MessageType = WampMessageType.v1Call; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("7DK6TdN4wLiUJgNM"); arguments[1] = new MockRaw("http://example.com/api#howdy"); mCallMessageForRpcWithNoArguments.Arguments = arguments; } mSubscribeMessageWithFullyQualifiedUri = new WampMessage <MockRaw>(); { mSubscribeMessageWithFullyQualifiedUri.MessageType = WampMessageType.v1Subscribe; MockRaw[] arguments = new MockRaw[1]; arguments[0] = new MockRaw("http://example.com/simple"); mSubscribeMessageWithFullyQualifiedUri.Arguments = arguments; } mSubscribeMessageWithCurie = new WampMessage <MockRaw>(); { mSubscribeMessageWithCurie.MessageType = WampMessageType.v1Subscribe; MockRaw[] arguments = new MockRaw[1]; arguments[0] = new MockRaw("event:myevent1"); mSubscribeMessageWithCurie.Arguments = arguments; } mUnsubscribeMessageWithCurie = new WampMessage <MockRaw>(); { mUnsubscribeMessageWithCurie.MessageType = WampMessageType.v1Unsubscribe; MockRaw[] arguments = new MockRaw[1]; arguments[0] = new MockRaw("event:myevent1"); mUnsubscribeMessageWithCurie.Arguments = arguments; } mUnsubscribeMessageWithFullyQualifiedUri = new WampMessage <MockRaw>(); { mUnsubscribeMessageWithFullyQualifiedUri.MessageType = WampMessageType.v1Unsubscribe; MockRaw[] arguments = new MockRaw[1]; arguments[0] = new MockRaw("http://example.com/simple"); mUnsubscribeMessageWithFullyQualifiedUri.Arguments = arguments; } mPublishMessageWithComplexObjectAsPayload = new WampMessage <MockRaw>(); { mPublishMessageWithComplexObjectAsPayload.MessageType = WampMessageType.v1Publish; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("http://example.com/event#myevent2"); arguments[1] = new MockRaw(new { rand = 0.0918703273457586, flag = false, num = 23, name = "Kross", created = new DateTime(2012, 3, 29, 10, 41, 9, 864), }); mPublishMessageWithComplexObjectAsPayload.Arguments = arguments; } mPublishMessageWithNullAsPayload = new WampMessage <MockRaw>(); { mPublishMessageWithNullAsPayload.MessageType = WampMessageType.v1Publish; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("http://example.com/simple"); arguments[1] = new MockRaw(null); mPublishMessageWithNullAsPayload.Arguments = arguments; } mPublishMessageWithStringAsPayload = new WampMessage <MockRaw>(); { mPublishMessageWithStringAsPayload.MessageType = WampMessageType.v1Publish; MockRaw[] arguments = new MockRaw[2]; arguments[0] = new MockRaw("http://example.com/simple"); arguments[1] = new MockRaw("Hello, world!"); mPublishMessageWithStringAsPayload.Arguments = arguments; } mPublishMessageWithComplexObjectAsPayloadExcludeMe = new WampMessage <MockRaw>(); { mPublishMessageWithComplexObjectAsPayloadExcludeMe.MessageType = WampMessageType.v1Publish; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("http://example.com/event#myevent2"); arguments[1] = new MockRaw(new { rand = 0.0918703273457586, flag = false, num = 23, name = "Kross", created = new DateTime(2012, 3, 29, 10, 41, 9, 864), }); arguments[2] = new MockRaw(true); mPublishMessageWithComplexObjectAsPayloadExcludeMe.Arguments = arguments; } mPublishMessageWithComplexObjectAsPayloadDontExcludeMe = new WampMessage <MockRaw>(); { mPublishMessageWithComplexObjectAsPayloadDontExcludeMe.MessageType = WampMessageType.v1Publish; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("http://example.com/event#myevent2"); arguments[1] = new MockRaw(new { rand = 0.0918703273457586, flag = false, num = 23, name = "Kross", created = new DateTime(2012, 3, 29, 10, 41, 9, 864), }); arguments[2] = new MockRaw(false); mPublishMessageWithComplexObjectAsPayloadDontExcludeMe.Arguments = arguments; } mPublishMessageWithExcludeList = new WampMessage <MockRaw>(); { mPublishMessageWithExcludeList.MessageType = WampMessageType.v1Publish; MockRaw[] arguments = new MockRaw[3]; arguments[0] = new MockRaw("event:myevent1"); arguments[1] = new MockRaw("hello"); arguments[2] = new MockRaw(new[] { "NwtXQ8rdfPsy-ewS", "dYqgDl0FthI6_hjb", }); mPublishMessageWithExcludeList.Arguments = arguments; } mPublishMessageWithEligibleList = new WampMessage <MockRaw>(); { mPublishMessageWithEligibleList.MessageType = WampMessageType.v1Publish; MockRaw[] arguments = new MockRaw[4]; arguments[0] = new MockRaw("event:myevent1"); arguments[1] = new MockRaw("hello"); arguments[2] = new MockRaw(new string[] { }); arguments[3] = new MockRaw(new[] { "NwtXQ8rdfPsy-ewS", }); mPublishMessageWithEligibleList.Arguments = arguments; } mPublishMessageWithExcludedAndEligibleList = new WampMessage <MockRaw>(); { mPublishMessageWithExcludedAndEligibleList.MessageType = WampMessageType.v1Publish; MockRaw[] arguments = new MockRaw[4]; arguments[0] = new MockRaw("event:myevent1"); arguments[1] = new MockRaw("hello"); arguments[2] = new MockRaw(new[] { "dYqgDl0FthI6_hjb", }); arguments[3] = new MockRaw(new[] { "NwtXQ8rdfPsy-ewS", }); mPublishMessageWithExcludedAndEligibleList.Arguments = arguments; } mWelcomeMessage = WampV1Messages.Welcome("v59mbCGDXZ7WTyxB", 1, "Autobahn/0.5.1"); mCallResultMessageWithNullResult = WampV1Messages.CallResult("CcDnuI2bl2oLGBzO", null); mCallResultMessageWithStringResult = WampV1Messages.CallResult("otZom9UsJhrnzvLa", "Awesome result .."); mCallResultMessageWithComplexObjectResult = WampV1Messages.CallResult("CcDnuI2bl2oLGBzO", new { value1 = 23, value2 = "singsing", value3 = true, modified = new DateTime(2012, 3, 29, 10, 29, 16, 625), }); mCallErrorMessageWithGenericError = WampV1Messages.CallError("gwbN3EDtFv6JvNV5", "http://autobahn.tavendo.de/error#generic", "math domain error"); mCallErrorMessageWithSpecificErrorAndIntegerInErrorDetails = WampV1Messages.CallError("7bVW5pv8r60ZeL6u", "http://example.com/error#number_too_big", "1001 too big for me, max is 1000", 1000); mCallErrorMessageWithListOfIntegersInErrorDetails = WampV1Messages.CallError("AStPd8RS60pfYP8c", "http://example.com/error#invalid_numbers", "one or more numbers are multiples of 3", new[] { 0, 3 }); mEventMessageWithStringAsPayload = WampV1Messages.Event("http://example.com/simple", "Hello, I am a simple event."); mEventMessageWithNullAsPayload = WampV1Messages.Event("http://example.com/simple", null); mEventMessageWithComplexObjectPayload = WampV1Messages.Event("http://example.com/event#myevent2", new { rand = 0.0918703273457586, flag = false, num = 23, name = "Kross", created = new DateTime(2012, 3, 29, 10, 41, 9, 864), }); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { MockRaw converted = value as MockRaw; serializer.Serialize(writer, converted.Value); }