public async Task WorkflowEngine_TriggerAsyncWithEntityWorkflowInstanceAndExistingWorkflowVariable_ReturnsTriggerResult() { // Arrange var instance = new LightSwitcher(); this.Context.Switchers.Add(instance); var workflow = Workflow.Create(instance.Id, instance.Type, instance.State, "tester"); workflow.AddVariable(new LightSwitcherWorkflowVariable { CanSwitch = true }); this.Context.Workflows.Add(workflow); await this.Context.SaveChangesAsync(); var param = new TriggerParam("SwitchOn", instance); // Act var triggerResult = await this.WorkflowEngine.TriggerAsync(param); // Assert Assert.IsNotNull(triggerResult); Assert.IsFalse(triggerResult.HasErrors); Assert.AreEqual(instance.State, triggerResult.CurrentState); Assert.AreEqual("On", triggerResult.CurrentState); Assert.IsTrue(param.HasVariables); }
private void MqttClient_OnTopicRecieved(object sender, string e) { LightSwitcher.BeginInvokeOnMainThread(() => { LightSwitcher.SetState(e == "on", true); }); }
void Start() { stairwellContents = GameObject.Find("StairwellContents"); interactableObjectsContainer = stairwellContents.transform.Find("InteractableObjects").gameObject; furnitureContainer = stairwellContents.transform.Find("Furniture").gameObject; houseContainer = stairwellContents.transform.Find("House").gameObject; musicSwitcher = GameObject.Find("Ambient Sound").transform.GetComponent <MusicSwitcher>(); lightSwitcher = GameObject.Find("RoomArrangerWithTeleport").GetComponent <LightSwitcher>(); upperRoomCopyStairwellContents = GameObject.Find("DummyRoomTop"); lowerRoomCopyStairwellContents = GameObject.Find("DummyRoomBottom"); lowerCopyRoomFurnitureContainer = lowerRoomCopyStairwellContents != null?lowerRoomCopyStairwellContents.transform.Find("Furniture").gameObject : null; triggerContainer = GameObject.Find("Gameplay"); bigCurtains = GameObject.FindGameObjectsWithTag("Curtains").Select(x => x.GetComponent <Animator>()).ToArray(); UnhighlightAllInteractableObjects(); DisableAllTriggers(); foreach (Renderer renderer in GameObject.FindObjectsOfType <Renderer>()) { renderer.material.SetFloat(highlightHideShaderPropertyName, highlightDisabledValue); } }
public async Task WorkflowEngine_Find_ReturnsTheDesiredIWorkflowInstance() { // Arrange var instance = new LightSwitcher(); this.Context.Switchers.Add(instance); var workflow = Workflow.Create(instance.Id, instance.Type, instance.State, "tester"); this.Context.Workflows.Add(workflow); await this.Context.SaveChangesAsync(); // Act var result = this.WorkflowEngine.Find(instance.Id, typeof(LightSwitcher)); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(LightSwitcher)); var resultInstance = result as LightSwitcher; Assert.AreEqual(resultInstance.Id, instance.Id); Assert.AreEqual(resultInstance.Type, instance.Type); Assert.AreEqual(resultInstance.State, instance.State); Assert.AreEqual(resultInstance.Assignee, instance.Assignee); }
public void Initialize() { LightSwitcher.TurnOff(); Door.TurnOff(); LightSensor.TurnOff(); MotionSensor.TurnOff(); ClassRoomObjects.Counter = 0; }
void Awake() { if (instance == null) { instance = this; } else { Destroy(transform.gameObject); } DontDestroyOnLoad(transform.gameObject); }
public MainPage() { InitializeComponent(); _lightSwitcher = new LightSwitcher(); _lightSwitcher.Initialize(); _listerner = new ReceiveBroker(); _listerner.OnReceivedMessage += _listerner_OnReceivedMessage; _listerner.Initialize(); _listerner.StartListening(); }
void ReleaseDesignerOutlets() { if (LightSwitcher != null) { LightSwitcher.Dispose(); LightSwitcher = null; } if (UISwitchController != null) { UISwitchController.Dispose(); UISwitchController = null; } }
static void Main(string[] args) { ISwitchable switcher = new LightSwitcher(); ICommand on = new PowerOnCommand(switcher); ICommand off = new PowerOffCommand(switcher); var invoker = new SwitchInvoker(on, off); Console.WriteLine("Lights ON =>"); invoker.LightOn(); Console.WriteLine(); Console.WriteLine("Lights OFF =>"); invoker.LightOff(); Console.WriteLine(); Console.ReadKey(); }
public async Task WorkflowEngine_TriggerAsyncWithEntityWorkflowInstance_ReturnsTriggerResult() { // Arrange var instance = new LightSwitcher(); var param = new TriggerParam("SwitchOn", instance); // Act var triggerResult = await this.WorkflowEngine.TriggerAsync(param); // Assert Assert.IsNotNull(triggerResult); Assert.IsFalse(triggerResult.HasErrors); Assert.AreEqual(instance.State, triggerResult.CurrentState); Assert.AreEqual("On", triggerResult.CurrentState); Assert.AreEqual(1, this.Context.Workflows.Count()); Assert.AreEqual(0, this.Context.Workflows.First().WorkflowVariables.Count()); }
public async Task WorkflowEngine_TriggerAsyncWithEntityWorkflowInstanceAndSameWorkflowVariable_ReturnsTriggerResult() { // Arrange var instance = new LightSwitcher(); this.Context.Switchers.Add(instance); var workflow = Workflow.Create(instance.Id, instance.Type, instance.State, "tester"); var variable = new LightSwitcherWorkflowVariable { CanSwitch = true }; workflow.AddVariable(variable); this.Context.Workflows.Add(workflow); await this.Context.SaveChangesAsync(); variable.CanSwitch = false; var param = new TriggerParam("SwitchOn", instance) .AddVariableWithKey <LightSwitcherWorkflowVariable>(variable);; // Act var triggerResult = await this.WorkflowEngine.TriggerAsync(param); // Assert Assert.IsNotNull(triggerResult); Assert.IsFalse(triggerResult.HasErrors); Assert.AreEqual(instance.State, triggerResult.CurrentState); Assert.AreEqual("On", triggerResult.CurrentState); Assert.IsTrue(param.HasVariables); Assert.AreEqual(1, workflow.WorkflowHistories.Count()); var workflowVariable = workflow.WorkflowVariables.First(); var type = KeyBuilder.FromKey(workflowVariable.Type); var myDeserializedVariable = JsonConvert.DeserializeObject(workflowVariable.Content, type); Assert.IsInstanceOfType(myDeserializedVariable, typeof(LightSwitcherWorkflowVariable)); var variableInstance = myDeserializedVariable as LightSwitcherWorkflowVariable; Assert.IsFalse(variableInstance.CanSwitch); }
public async Task WorkflowEngineService_TriggerAsyncWithEntityWorkflowInstanceAndNewWorkflowVariable_ReturnsTriggerResult() { // Arrange var instance = new LightSwitcher(); var workfowVariable = new LightSwitcherWorkflowVariable { CanSwitch = true }; var param = new TriggerParam("SwitchOn", instance) .AddVariableWithKey <LightSwitcherWorkflowVariable>(workfowVariable); // Act var triggerResult = await this.WorkflowEngineService.TriggerAsync(param); // Assert Assert.NotNull(triggerResult); Assert.False(triggerResult.HasErrors); Assert.Equal(instance.State, triggerResult.CurrentState); Assert.Equal("On", triggerResult.CurrentState); Assert.Equal(1, this.Context.Workflows.Count()); Assert.Single(this.Context.Workflows.First().WorkflowVariables); }