public void Can_send_non_function() { INetJsValue jsValue = null; Mock.Setup(x => x.Method(It.IsAny <INetJsValue>())) .Callback(new Action <dynamic>(x => { jsValue = x; })); NetTestHelper.RunQml(qmlApplicationEngine, @" import QtQuick 2.0 import tests 1.0 JsTestsQml { id: test Component.onCompleted: function() { test.method({}) } } "); Mock.Verify(x => x.Method(It.IsAny <INetJsValue>()), Times.Once); jsValue.Should().NotBeNull(); jsValue.IsCallable.Should().BeFalse(); }
public void Can_send_function() { INetJsValue jsValue = null; Mock.Setup(x => x.Method(It.IsAny <INetJsValue>())) .Callback(new Action <dynamic>(x => jsValue = x)); RunQmlTest( "test", @" test.method(function(){}) "); Mock.Verify(x => x.Method(It.IsAny <INetJsValue>()), Times.Once); jsValue.Should().NotBeNull(); jsValue.IsCallable.Should().BeTrue(); }