Inheritance: JsEventObject
Beispiel #1
0
 public void EventObjectWorks()
 {
     ManualResetEvent wait = new ManualResetEvent(false);
     EventsTestsObject eventTest = new EventsTestsObject(scriptRunner);
     bool set = false;
     scriptRunner.BeginInvoke((runner) =>
     {
         scriptRunner.Engine.SetGlobalFunction("fin", new Action(() =>
         {
             set = true;
             wait.Set();
         }));
         scriptRunner.Engine.SetGlobalValue("test", eventTest);
     });
     scriptRunner.Execute("test.listen('test', fin);");
     eventTest.Test();
     wait.WaitOne(100);
     set.Should().Be.True();
 }
Beispiel #2
0
 public void EventsAreSettableAsObject()
 {
     ManualResetEvent wait = new ManualResetEvent(false);
     int count = 0;
     EventsTestsObject eventTest = new EventsTestsObject(scriptRunner);
     scriptRunner.BeginInvoke(runner =>
     {
         scriptRunner.Engine.SetGlobalFunction("fin", new Action(() =>
         {
             if (++count > 1)
                 wait.Set();
         }));
         scriptRunner.Engine.SetGlobalValue("test", eventTest);
     });
     scriptRunner.Execute("test.listen({test:fin,test2:fin});");
     eventTest.Test();
     eventTest.Test2();
     wait.WaitOne(100);
     count.Should().Equal(2);
 }
Beispiel #3
0
 public void EventObjectFiresWithArguments()
 {
     ManualResetEvent wait = new ManualResetEvent(false);
     EventsTestsObject eventTest = new EventsTestsObject(scriptRunner);
     string value = null;
     bool set = false;
     scriptRunner.BeginInvoke((runner) =>
     {
         scriptRunner.Engine.SetGlobalFunction("fin", new Action<string>(val =>
         {
             value = val;
             set = true;
             wait.Set();
         }));
         scriptRunner.Engine.SetGlobalValue("test", eventTest);
     });
     scriptRunner.Execute("test.listen('test', fin);");
     eventTest.Test("test_value");
     wait.WaitOne(100);
     set.Should().Be.True();
     value.Should().Equal("test_value");
 }