public void SimpleMapDictTest() { const string testString = "This is a test"; NotificationParamType testKey = NotificationParamType.Subject; const string testValue = "value1"; Command pCommand = null; var i = new Netomity.Interfaces.Basic.Fakes.StubBasicInterface(); var ha = new Netomity.Interfaces.HA.Fakes.StubHAInterface(iface: i); ha.CommandCommand = (command) => { pCommand = command; return(Task.Run(() => { return true; })); }; var m = new MapCommand(primaryInput: CommandType.On, primaryOutput: CommandType.Off, secondaryOutput: testString, stringParams: new Dictionary <StringEnum, string>() { { testKey, testValue } }); var sd = new StateDevice(iface: ha, behaviors: new List <BehaviorBase>() { m }); Assert.AreEqual(StateType.Unknown, sd.State.Primary); var r = sd.On(); Assert.IsTrue(r.Result); Assert.AreEqual(StateType.Off, sd.State.Primary); Assert.AreEqual(CommandType.Off, pCommand.Primary); Assert.AreEqual(testString, pCommand.Secondary); Assert.AreEqual(testValue, pCommand.StringParams[testKey]); }
public void SpecificMatchFirst() { var motion = new StateDevice(); var m = new MapCommand( primaryInput: CommandType.On, primaryOutput: CommandType.Off ); m.Add( primaryInput: CommandType.On, primaryOutput: CommandType.Unknown, sourceObject: motion ); var sd = new StateDevice( devices: new List <StateDevice>() { motion }, behaviors: new List <BehaviorBase>() { m }); Assert.AreEqual(StateType.Unknown, sd.State.Primary); sd.Command(primary: CommandType.On); Assert.AreEqual(StateType.Off, sd.State.Primary); motion.Command(primary: CommandType.On); Assert.AreEqual(StateType.Unknown, sd.State.Primary); }
public InGameState(Bot bot) { Value = StateType.InGame; Command = new MapCommand(bot); MessagesKnown = new List <MessageType> { new MessageType(PrefixMessage.MapLoading.GetInfo) }; }
/// <inheritdoc/> public override void ProcessInteraction(DiagramInteractionEventArguments interaction) { var diagram = interaction.Diagram; var selectedNodes = diagram.Nodes.Where(n => n.IsSelected).ToArray(); var unwireAndRemoveAllNodesCommand = new MapCommand(new UnwireAndDeleteNodeCommand(diagram)); _transactor.Transact(unwireAndRemoveAllNodesCommand, selectedNodes); if (!diagram.Nodes.Any()) { diagram.ResetPanAndZoom(); } }
public void TestSendMapCommand(int command, int number, int x, int y) { var mapItem = new MapItem(Map.Trammel); var expected = new MapCommand(mapItem, command, number, x, y).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); ns.SendMapCommand(mapItem, command, x, y, number > 0); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }
public void SimpleMapOverlayTest() { const string testSecondary = "This is a test"; var m = new MapCommand(primaryInput: CommandType.On, primaryOutput: CommandType.Off); var c = new Command() { Primary = CommandType.On, Secondary = testSecondary, }; var rC = m.FilterCommand(c); Assert.AreEqual(testSecondary, rC.Secondary); }
static int Main(string[] args) { var root = new RootCommand() { MapCommand.Build(), new System.CommandLine.Command("legacy", "これまでの Observers CLI を起動します") { Handler = CommandHandler.Create(() => { GrcpMain(); }) }, }; return(root.InvokeAsync(args).Result); }
public void SetUp() { _logger = new FakeLogger(); _config = new Configuration { ApiKey = "key", UrlRoot = "http://something" }; _cache = new MemoryCache(new MemoryCacheOptions()); _fakeGenerator = new FakeGenerator { Returns = new byte[0] }; _knownLocations = new LocationCollection { new Location("Foo", new ImageLocation(10, 10)), new Location("Foo Bar"), }; _sut = new MapCommand(_knownLocations, _fakeGenerator, _cache); }
public void DoubleMapTest() { var m = new MapCommand(primaryInput: CommandType.On, primaryOutput: CommandType.Off); m.Add(primaryInput: CommandType.Off, primaryOutput: CommandType.On, secondaryOutput: "test"); var sd = new StateDevice(behaviors: new List <BehaviorBase>() { m }); Assert.AreEqual(StateType.Unknown, sd.State.Primary); sd.On(); Assert.AreEqual(StateType.Off, sd.State.Primary); Assert.IsNull(sd.State.Secondary); sd.Off(); Assert.AreEqual(StateType.On, sd.State.Primary); Assert.AreEqual("test", sd.State.Secondary); }
public void DelayTest() { var m = new MapCommand( primaryInput: CommandType.Motion, primaryOutput: CommandType.Off, delaySecs: 2); var sd = new StateDevice(behaviors: new List <BehaviorBase>() { m }); Assert.AreEqual(StateType.Unknown, sd.State.Primary); sd.Command(primary: CommandType.Motion); Assert.AreEqual(StateType.Unknown, sd.State.Primary); Thread.Sleep(1000); Assert.AreEqual(StateType.Unknown, sd.State.Primary); Thread.Sleep(2000); Assert.AreEqual(StateType.Off, sd.State.Primary); }
public void FunctionalLightGutsTest() { // Motion Sensor driven light with a delay off time of 2 secs var motion = new StateDevice() { Name = "Motion1" }; var mapping = new MapCommand( primaryInput: CommandType.Motion, primaryOutput: CommandType.On ); mapping.Add( primaryInput: CommandType.Motion, primaryOutput: CommandType.Off, delaySecs: 2 ); var sd = new StateDevice( devices: new List <StateDevice>() { motion }, behaviors: new List <BehaviorBase>() { mapping } ) { Name = "StateDevice1" }; Assert.AreEqual(StateType.Unknown, sd.State.Primary); sd.Command(primary: CommandType.Motion); Assert.AreEqual(StateType.On, sd.State.Primary); Thread.Sleep(3000); Assert.AreEqual(StateType.Off, sd.State.Primary); }
public TDestinationCommand Execute(MapCommand <TSource, TDestinationCommand> command) { var destinationCommand = _objectMapper.Map <TSource, TDestinationCommand>(command.Source()); return(destinationCommand); }
/// <summary> /// Sets a tool as a command. /// </summary> /// <param name="command">The new tool that is currently selected.</param> public void SetCommand(MapCommand command) => ((MapEditorMouseControl)mcc).selectedCommand = command;