示例#1
0
        public void ClipboardModule_ArgumentChecks()
        {
            var clipboard = new MockClipboardInstance();
            var module    = new ClipboardModule(clipboard);

            AssertEx.Throws <ArgumentNullException>(
                () => module.getString(null),
                ex => Assert.AreEqual("promise", ex.ParamName));
        }
示例#2
0
        public void ClipboardModule_SetString_Null_Method()
        {
            var clipboard = new MockClipboardInstance();
            var module    = new ClipboardModule(clipboard);

            var result     = "";
            var waitHandle = new AutoResetEvent(false);

            var promise = new MockPromise(resolve => { result = resolve.ToString(); waitHandle.Set(); },
                                          (code, message, stack, userInfo) => { result = message; waitHandle.Set(); });

            module.setString(null);
            module.getString(promise);

            waitHandle.WaitOne();
            Assert.AreEqual("", result);
        }
        public void ClipboardModule_GetString_Method()
        {
            var clipboard = new MockClipboardInstance();
            var module    = new ClipboardModule(clipboard);

            var result     = "";
            var str        = "test string";
            var waitHandle = new AutoResetEvent(false);

            var promise = new MockPromise(resolve => { result = resolve.ToString(); waitHandle.Set(); },
                                          (code, message, e) => { result = message; waitHandle.Set(); });

            module.setString(str);
            module.getString(promise);

            waitHandle.WaitOne();
            Assert.AreEqual(str, result);
        }