public void Requests_Null_Method_Call() { var messenger = Substitute.For <IBinaryMessenger>(); var channel = new MethodChannel(TEST_CHANNEL_NAME, StandardMethodCodec.Instance, messenger); Assert.Throws <ArgumentNullException>(() => channel.InvokeMethod(null)); }
private void SendResult(FlutnetMethodInfo methodInfo, object result) { Dictionary <string, object> resultValue = new Dictionary <string, object>(); resultValue.Add("ReturnValue", result); FlutnetMessage message = new FlutnetMessage { MethodInfo = methodInfo, Result = resultValue }; Object dartReturnValue = FlutterInterop.ToMethodChannelResult(message); Console.WriteLine("Sending result to Flutter..."); MainThread.BeginInvokeOnMainThread(() => _methodChannelIncoming.InvokeMethod("result", dartReturnValue)); }
public void Requests_Correct_MethodCall() { var messenger = Substitute.For <IBinaryMessenger>(); var codec = StandardMethodCodec.Instance; var channel = new MethodChannel(TEST_CHANNEL_NAME, codec, messenger); var call = new MethodCall(TEST_METHOD_NAME, new int[] { 1, 2, 5 }); channel.InvokeMethod(call.Method, call.Arguments); messenger.Received().Send(Arg.Is <string>(x => x == TEST_CHANNEL_NAME), Arg.Is <byte[]>(x => x.SequenceEqual(codec.EncodeMethodCall(call)))); }