public void Render() { InvokeMethodAction a = new InvokeMethodAction(); StringWriter sw; ScriptTextWriter w; // test an empty action sw = new StringWriter(); w = new ScriptTextWriter(sw); a.RenderAction(w); Assert.AreEqual("<invokeMethod />", sw.ToString(), "A1"); // test with a target a.Method = "method"; sw = new StringWriter(); w = new ScriptTextWriter(sw); a.RenderAction(w); Assert.AreEqual("<invokeMethod method=\"method\" />", sw.ToString(), "A2"); // test with a target and id a.ID = "invoke_id"; a.Method = "method"; sw = new StringWriter(); w = new ScriptTextWriter(sw); a.RenderAction(w); Assert.AreEqual("<invokeMethod id=\"invoke_id\" method=\"method\" />", sw.ToString(), "A3"); }
public void IsTypeDescriptorClosed() { InvokeMethodAction a = new InvokeMethodAction(); ScriptTypeDescriptor desc = ((IScriptObject)a).GetTypeDescriptor(); desc.AddEvent(new ScriptEventDescriptor("testEvent", true)); }
public void TypeDescriptor() { InvokeMethodAction a = new InvokeMethodAction(); ScriptTypeDescriptor desc = ((IScriptObject)a).GetTypeDescriptor(); Assert.AreEqual(a, desc.ScriptObject, "A1"); // events IEnumerable <ScriptEventDescriptor> events = desc.GetEvents(); Assert.IsNotNull(events, "A2"); IEnumerator <ScriptEventDescriptor> ee = events.GetEnumerator(); Assert.IsTrue(ee.MoveNext()); DoEvent(ee.Current, "propertyChanged", true); Assert.IsFalse(ee.MoveNext()); // methods IEnumerable <ScriptMethodDescriptor> methods = desc.GetMethods(); Assert.IsNotNull(methods, "A3"); IEnumerator <ScriptMethodDescriptor> me = methods.GetEnumerator(); Assert.IsFalse(me.MoveNext()); // properties IEnumerable <ScriptPropertyDescriptor> props = desc.GetProperties(); Assert.IsNotNull(props, "A4"); IEnumerator <ScriptPropertyDescriptor> pe = props.GetEnumerator(); Assert.IsTrue(pe.MoveNext(), "A5"); DoProperty(pe.Current, "bindings", ScriptType.Array, true, "Bindings"); Assert.IsTrue(pe.MoveNext(), "A6"); DoProperty(pe.Current, "dataContext", ScriptType.Object, false, ""); Assert.IsTrue(pe.MoveNext(), "A7"); DoProperty(pe.Current, "id", ScriptType.String, false, "ID"); Assert.IsTrue(pe.MoveNext(), "A8"); DoProperty(pe.Current, "eventArgs", ScriptType.Object, false, ""); Assert.IsTrue(pe.MoveNext(), "A9"); DoProperty(pe.Current, "result", ScriptType.Object, false, ""); Assert.IsTrue(pe.MoveNext(), "A10"); DoProperty(pe.Current, "sender", ScriptType.Object, false, ""); Assert.IsTrue(pe.MoveNext(), "A11"); DoProperty(pe.Current, "sequence", ScriptType.Enum, false, "Sequence"); Assert.IsTrue(pe.MoveNext(), "A12"); DoProperty(pe.Current, "target", ScriptType.Object, false, "Target"); Assert.IsTrue(pe.MoveNext(), "A13"); DoProperty(pe.Current, "method", ScriptType.String, false, "Method"); Assert.IsFalse(pe.MoveNext(), "A14"); }
public void Properties() { InvokeMethodAction a = new InvokeMethodAction(); // default Assert.AreEqual("", a.Method, "A1"); Assert.AreEqual("invokeMethod", a.TagName, "A2"); // getter/setter a.Method = "method"; Assert.AreEqual("method", a.Method, "A3"); // setting to null a.Method = null; Assert.AreEqual("", a.Method, "A4"); }
static async Task DoAction(CmdArguments args) { switch (args.Action) { case Action.AddDevices: await AddDeviceAction.Do(args); break; case Action.DeleteDevices: await DeleteDeviceAction.Do(args); break; case Action.QueryDevices: await QueryDevicesAction.Do(args); break; case Action.UpdateTwin: await UpdateTwinAction.Do(args); break; case Action.ScheduleTwinUpdate: await ScheduleTwinUpdateAction.Do(args); break; case Action.InvokeMethod: await InvokeMethodAction.Do(args); break; case Action.ScheduleDeviceMethod: await ScheduleDeviceMethodAction.Do(args); break; case Action.QueryJobs: await QueryJobsAction.Do(args); break; case Action.QueryJobSummary: await QueryJobSummaryAction.Do(args); break; case Action.CancelJobs: await CancelJobsAction.Do(args); break; case Action.SendMessage: await SendMessageAction.Do(args); break; default: throw new ApplicationException($"Unexpected action: {args.Action}"); } }
public void SetUp() { _targetObject = new Test(); _testee = new InvokeMethodAction(_targetObject, "TestMethod"); }