public async Task ArgumentsStarsDefaultValues(string nick, int?stars, string result) { WampPlayground playground = new WampPlayground(); var channel = await SetupService <ArgumentsService>(playground); MockRawCallback callback = new MockRawCallback(); Dictionary <string, object> argumentsKeywords = new Dictionary <string, object>(); if (nick != null) { argumentsKeywords["nick"] = nick; } if (stars != null) { argumentsKeywords["stars"] = stars; } channel.RealmProxy.RpcCatalog.Invoke (callback, new CallOptions(), "com.arguments.stars", new object[0], argumentsKeywords); Assert.That(callback.Arguments.Select(x => x.Deserialize <string>()), Is.EquivalentTo(new[] { result })); }
public async Task LongPositionalTupleServiceCallee() { WampPlayground playground = new WampPlayground(); var channel = await SetupService <LongValueTuplesCalleeService>(playground); MockRawCallback callback = new MockRawCallback(); string name = "Homer Simpson"; channel.RealmProxy.RpcCatalog.Invoke (callback, new CallOptions(), "com.myapp.get_long_positional_tuple", new object[] { name }, new Dictionary <string, object>()); int count = callback.Arguments.Count() - 1; Assert.That(callback.Arguments.Take(count).Select(x => x.Deserialize <string>()), Is.EquivalentTo(Enumerable.Range(1, 10).Select(index => name + " " + index))); Assert.That(callback.Arguments.Last().Deserialize <int>(), Is.EqualTo(name.Length)); Assert.That(callback.ArgumentsKeywords, Is.Null); }
public async Task ComplexPositionalTupleServiceAddComplex() { WampPlayground playground = new WampPlayground(); var channel = await SetupService <PositionalTupleComplexResultService>(playground); MockRawCallback callback = new MockRawCallback(); Dictionary <string, object> argumentsKeywords = new Dictionary <string, object>() { { "a", 2 }, { "ai", 3 }, { "b", 4 }, { "bi", 5 } }; channel.RealmProxy.RpcCatalog.Invoke (callback, new CallOptions(), "com.myapp.add_complex", new object[0], argumentsKeywords); Assert.That(callback.Arguments.Select(x => x.Deserialize <int>()), Is.EquivalentTo(new[] { 6, 8 })); }
public async Task LongKeywordTupleServiceCallee() { WampPlayground playground = new WampPlayground(); var channel = await SetupService <LongValueTuplesCalleeService>(playground); MockRawCallback callback = new MockRawCallback(); string name = "Homer Simpson"; channel.RealmProxy.RpcCatalog.Invoke (callback, new CallOptions(), "com.myapp.get_long_keyword_tuple", new object[] { name }, new Dictionary <string, object>()); int count = callback.Arguments.Count() - 1; Dictionary <string, object> resultDictionary = callback.ArgumentsKeywords.Where(x => x.Key.StartsWith("item")) .ToDictionary(x => x.Key, x => (object)x.Value.Deserialize <string>()); resultDictionary["length"] = callback.ArgumentsKeywords["length"].Deserialize <int>(); Dictionary <string, object> expectedDicionary = Enumerable.Range(1, 10) .ToDictionary(index => "item" + index, index => (object)(name + " " + index)); expectedDicionary["length"] = name.Length; Assert.That(callback.ArgumentsKeywords.Keys, Is.EquivalentTo(expectedDicionary.Keys)); Assert.That(resultDictionary, Is.EquivalentTo(expectedDicionary)); Assert.That(callback.Arguments, Is.Empty); }