Esempio n. 1
0
        public void TestSimpleLargeObjectArrayArgument()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    var parameter = new List <ParameterObject>();
                    for (int i = 0; i < 1000; i++)
                    {
                        parameter.Add(new ParameterObject());
                    }

                    var result = bridge.InvokeFunction <List <ParameterObject> >("anObject.simpleArgumentFunction", parameter);
                    Assert.Equal(parameter.Count, result.Count);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 2
0
        public void TestBrowserTestForm()
        {
            using (var form = new BrowserTestForm())
            {
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) => { waiter.SetEvent(); };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 3
0
        public void TestBrowserTestForm()
        {
            using (var form = new BrowserTestForm())
            {

                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) => { waiter.SetEvent(); };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 4
0
        public void TestUndefinedContextCall()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    Assert.Throws <Exception>(() => bridge.InvokeFunction <string>("undefinedContext.someFunc"));
                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 5
0
        public void TestGlobalFunctionCall()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    var result = bridge.InvokeFunction <string>("globalFunction");
                    Assert.Equal("globalFunction", result);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 6
0
        public void TestAutoInitialization()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    // Check that the bridge is initialized.
                    Assert.True(bridge.IsInitialized);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 7
0
        public void TestSimpleFunctionArrayArgument()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    var parameter = new int[] { 1, 2, 3, 4, 5 };
                    var result    = bridge.InvokeFunction <int[]>("anObject.simpleArgumentFunction", parameter);
                    Assert.Equal(parameter, result);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 8
0
        public void TestGlobalFunctionCall()
        {
            using (var form = new BrowserTestForm())
            {

                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {

                    var result = bridge.InvokeFunction<string>("globalFunction");
                    Assert.Equal("globalFunction", result);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 9
0
        public void TestAutoInitialization()
        {
            using (var form = new BrowserTestForm())
            {

                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {

                    // Check that the bridge is initialized.
                    Assert.True(bridge.IsInitialized);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 10
0
        public void TestUndefinedContextCall()
        {
            using (var form = new BrowserTestForm())
            {

                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {

                    Assert.Throws<Exception>(() => bridge.InvokeFunction<string>("undefinedContext.someFunc"));
                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 11
0
        public void TestSimpleLargeObjectArrayArgument()
        {
            using (var form = new BrowserTestForm())
            {

                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {

                    var parameter = new List<ParameterObject>();
                    for (int i = 0; i < 1000; i++)
                        parameter.Add(new ParameterObject());

                    var result = bridge.InvokeFunction<List<ParameterObject>>("anObject.simpleArgumentFunction", parameter);
                    Assert.Equal(parameter.Count, result.Count);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Esempio n. 12
0
        public void TestSimpleFunctionArrayArgument()
        {
            using (var form = new BrowserTestForm())
            {

                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {

                    var parameter = new int[] { 1, 2, 3, 4, 5 };
                    var result = bridge.InvokeFunction<int[]>("anObject.simpleArgumentFunction", parameter);
                    Assert.Equal(parameter, result);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }