public async Task TestNode2RuleDispatch() { var source = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "Source", Dispatcher, NodeInstanceCache, DriverNodesStore); var target = await DispatcherHelperUtils.CreateLogicMock("Target", Dispatcher, null, LogicInterfaceInstanceCache, LogicInstancesStore); CreateLink(a => { a.This2RuleInterfaceInstanceInputNavigation = new RuleInterfaceInstance() { ObjId = target.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Input").ObjId, This2RuleInstance = target.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Input").This2RuleInstance }; a.This2NodeInstance2RulePageOutputNavigation = new NodeInstance2RulePage { This2NodeInstance = source.Children[0].DriverContext.NodeInstance.ObjId }; }); RuleEngineDispatcher.Load(); await Dispatcher.DispatchValue(source.Children[0], true); await Task.Delay(200); Assert.True(target.WriteReceived); var value = Dispatcher.GetValue(DispatchableType.NodeInstance, source.Children[0].Id); Assert.IsType <bool>(value); Assert.True((bool)value); }
public async Task TestLoopNode2Rule() { var source = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "Source", Dispatcher, NodeInstanceCache, DriverNodesStore); var target = await DispatcherHelperUtils.CreateLogicMock("Target", Dispatcher, null, LogicInterfaceInstanceCache, LogicInstancesStore); CreateLink(a => { a.This2RuleInterfaceInstanceInputNavigation = new RuleInterfaceInstance { This2RuleInstance = target.Context.RuleInstance.RuleInterfaceInstance.Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Input").ObjId }; a.This2NodeInstance2RulePageOutputNavigation = new NodeInstance2RulePage { This2NodeInstance = source.Children[0].DriverContext.NodeInstance.ObjId }; }); CreateLink(a => { a.This2RuleInterfaceInstanceOutputNavigation = new RuleInterfaceInstance { This2RuleInstance = target.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Output").ObjId }; a.This2NodeInstance2RulePageInputNavigation = new NodeInstance2RulePage { This2NodeInstance = source.Children[0].DriverContext.NodeInstance.ObjId }; }); RuleEngineDispatcher.Load(); await Dispatcher.DispatchValue(source.Children[0], true); }
public async Task TestNode2NodeDispatch() { var source = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "Source", Dispatcher, NodeInstanceCache, DriverNodesStore); var target = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "Target", Dispatcher, NodeInstanceCache, DriverNodesStore); CreateLink(a => { a.This2NodeInstance2RulePageInputNavigation = new NodeInstance2RulePage { This2NodeInstance = target.Children[0].DriverContext.NodeInstance.ObjId }; a.This2NodeInstance2RulePageOutputNavigation = new NodeInstance2RulePage { This2NodeInstance = source.Children[0].DriverContext.NodeInstance.ObjId }; }); RuleEngineDispatcher.Load(); await Dispatcher.DispatchValue(source.Children[0], true); await Task.Delay(200); Assert.True(((DriverNodeMock)target.Children[0]).WriteReceived); var value = Dispatcher.GetValue(DispatchableType.NodeInstance, source.Children[0].Id); Assert.IsType <bool>(value); Assert.True((bool)value); }
public async Task TestLoopNodes() { var source = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "Source", Dispatcher, NodeInstanceCache, DriverNodesStore); var target = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "Target", Dispatcher, NodeInstanceCache, DriverNodesStore); var target2 = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "Target_Loop_Back", Dispatcher, NodeInstanceCache, DriverNodesStore); CreateLink(a => { a.This2NodeInstance2RulePageInputNavigation = new NodeInstance2RulePage { This2NodeInstance = target.Children[0].DriverContext.NodeInstance.ObjId } ; a.This2NodeInstance2RulePageOutputNavigation = new NodeInstance2RulePage { This2NodeInstance = source.Children[0].DriverContext.NodeInstance.ObjId }; }); CreateLink(a => { a.This2NodeInstance2RulePageInputNavigation = new NodeInstance2RulePage { This2NodeInstance = target2.Children[0].DriverContext.NodeInstance.ObjId }; a.This2NodeInstance2RulePageOutputNavigation = new NodeInstance2RulePage { This2NodeInstance = target.Children[0].DriverContext.NodeInstance.ObjId }; }); CreateLink(a => { a.This2NodeInstance2RulePageInputNavigation = new NodeInstance2RulePage { This2NodeInstance = source.Children[0].DriverContext.NodeInstance.ObjId }; a.This2NodeInstance2RulePageOutputNavigation = new NodeInstance2RulePage { This2NodeInstance = target2.Children[0].DriverContext.NodeInstance.ObjId }; }); RuleEngineDispatcher.Load(); await Dispatcher.DispatchValue(source.Children[0], true); }
public async Task TryGetValues() { var driverMock = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "MockName", DispatcherMock.Instance); await DispatcherMock.Instance.DispatchValue(driverMock, true); var values = DispatcherMock.Instance.GetValues(DispatchableType.NodeInstance); Assert.True(values.ContainsKey(driverMock.Id)); }
public async Task WriteDirect() { var driverMock = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "MockName", DispatcherMock.Instance); var driverMock2 = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "MockName2", DispatcherMock.Instance); await driverMock.WriteValue(driverMock2, true); Assert.True(driverMock.WriteReceived); }
public async Task TryGetValue() { var driverMock = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "MockName", DispatcherMock.Instance); await DispatcherMock.Instance.DispatchValue(driverMock, true); var value = DispatcherMock.Instance.GetValue(DispatchableType.NodeInstance, driverMock.Id); Assert.IsType <bool>(value); Assert.True((bool)value); }
public async Task TestDispatcherClear() { var driverMock2 = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "MockName2", DispatcherMock.Instance); await DispatcherMock.Instance.RegisterDispatch(DispatchableType.NodeInstance, DispatchableMock.Instance.Id, (a, b) => { ((DriverNodeMock)driverMock2.Children[0]).WriteValue(a, b); }); await DispatcherMock.Instance.ClearRegistrations(); await DispatcherMock.Instance.DispatchValue(DispatchableMock.Instance, true); Assert.False(((DriverNodeMock)driverMock2.Children[0]).WriteReceived); }
public async Task WriteDispatcher() { var driverMock = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "MockName", DispatcherMock.Instance); var driverMock2 = await DispatcherHelperUtils.CreateNodeMock(Guid.NewGuid(), "MockName2", DispatcherMock.Instance); await DispatcherMock.Instance.RegisterDispatch(DispatchableType.NodeInstance, driverMock.Id, (a, b) => { ((DriverNodeMock)driverMock2.Children[0]).WriteValue(a, b); }); await DispatcherMock.Instance.DispatchValue(driverMock, true); await Task.Delay(200); Assert.True(((DriverNodeMock)driverMock2.Children[0]).WriteReceived); }
public async Task TestRule2RuleDispatch() { var source = await DispatcherHelperUtils.CreateLogicMock("Source", Dispatcher, null, LogicInterfaceInstanceCache, LogicInstancesStore); var target = await DispatcherHelperUtils.CreateLogicMock("Target", Dispatcher, null, LogicInterfaceInstanceCache, LogicInstancesStore); var outputInterface = source.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Output"); var inputInterface = target.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Input"); CreateLink(a => { a.This2RuleInterfaceInstanceInputNavigation = new RuleInterfaceInstance() { This2RuleInstance = inputInterface.ObjId }; a.This2RuleInterfaceInstanceInput = inputInterface.ObjId; a.This2RuleInterfaceInstanceOutputNavigation = new RuleInterfaceInstance() { This2RuleInstance = outputInterface.ObjId }; a.This2RuleInterfaceInstanceOutput = outputInterface.ObjId; }); RuleEngineDispatcher.Load(); await Dispatcher.DispatchValue(new RuleInterfaceInstanceDispatchable(outputInterface), true); await Task.Delay(200); Assert.True(target.WriteReceived); var value = Dispatcher.GetValue(DispatchableType.RuleInstance, outputInterface.ObjId); Assert.IsType <bool>(value); Assert.True((bool)value); }
public async Task TestLoopRules() { var source = await DispatcherHelperUtils.CreateLogicMock("Source", Dispatcher, null, LogicInterfaceInstanceCache, LogicInstancesStore); var target = await DispatcherHelperUtils.CreateLogicMock("Target", Dispatcher, null, LogicInterfaceInstanceCache, LogicInstancesStore); var target2 = await DispatcherHelperUtils.CreateLogicMock("Target_Loop_Back", Dispatcher, null, LogicInterfaceInstanceCache, LogicInstancesStore); var inputInterfaceSource = source.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Input"); var outputInterface = source.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Output"); var inputInterface = target.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Input"); var outputInterface2 = target.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Output"); var inputInterfaceLoop = target2.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Input"); var outputInterfaceLoop = target2.Context.RuleInstance.RuleInterfaceInstance .Single(b => b.This2RuleInterfaceTemplateNavigation.Name == "Output"); CreateLink(a => { a.This2RuleInterfaceInstanceInputNavigation = new RuleInterfaceInstance { This2RuleInstance = inputInterface.ObjId }; a.This2RuleInterfaceInstanceOutputNavigation = new RuleInterfaceInstance { This2RuleInstance = outputInterface.ObjId }; }); CreateLink(a => { a.This2RuleInterfaceInstanceInputNavigation = new RuleInterfaceInstance { This2RuleInstance = inputInterfaceLoop.ObjId }; a.This2RuleInterfaceInstanceOutputNavigation = new RuleInterfaceInstance { This2RuleInstance = outputInterface2.ObjId }; }); CreateLink(a => { a.This2RuleInterfaceInstanceInputNavigation = new RuleInterfaceInstance { This2RuleInstance = inputInterfaceSource.ObjId }; a.This2RuleInterfaceInstanceOutputNavigation = new RuleInterfaceInstance { This2RuleInstance = outputInterfaceLoop.ObjId }; }); RuleEngineDispatcher.Load(); await Dispatcher.DispatchValue(new RuleInterfaceInstanceDispatchable(outputInterface), true); }