Exemplo n.º 1
0
        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]);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public InGameState(Bot bot)
 {
     Value         = StateType.InGame;
     Command       = new MapCommand(bot);
     MessagesKnown = new List <MessageType> {
         new MessageType(PrefixMessage.MapLoading.GetInfo)
     };
 }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        public TDestinationCommand Execute(MapCommand <TSource, TDestinationCommand> command)
        {
            var destinationCommand = _objectMapper.Map <TSource, TDestinationCommand>(command.Source());

            return(destinationCommand);
        }
Exemplo n.º 13
0
 /// <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;