Esempio n. 1
0
        public void FilterCommandOneTest()
        {
            var IsValid = false;

            var commandOutput = new Command()
            {
                Primary = CommandType.On
            };


            var b = new Netomity.Devices.Behaviors.Fakes.StubBehaviorBase
            {
                FilterCommandCommand = (c) => {
                    IsValid = c.Primary == CommandType.Off ? true : false;
                    return(commandOutput);
                }
            };

            var sd = new StateDevice(behaviors: new List <BehaviorBase>()
            {
                b
            });

            sd.Command(primary: CommandType.Off);
            Assert.AreEqual(sd.State.Primary, StateType.On);
        }
Esempio n. 2
0
        public void StateDeviceBevaiorRegister()
        {
            var WasCalled = false;
            var b         = new Netomity.Devices.Behaviors.Fakes.StubBehaviorBase
            {
                RegisterStateDevice = (l) => { WasCalled = true; }
            };

            Assert.IsFalse(WasCalled);
            var sd = new StateDevice(behaviors: new List <BehaviorBase>()
            {
                b
            });

            Assert.IsTrue(WasCalled);
        }
Esempio n. 3
0
        public void FilterPriorityTest2()
        {
            NetomityObject lastCalled = null;

            var commandOutput = new Command()
            {
                Primary = CommandType.On
            };


            var b1 = new Netomity.Devices.Behaviors.Fakes.StubBehaviorBase()
            {
                Priority = BehaviorPriority.Medium
            };

            b1.FilterCommandCommand = (c) =>
            {
                lastCalled = b1;
                return(commandOutput);
            };

            var b2 = new Netomity.Devices.Behaviors.Fakes.StubBehaviorBase()
            {
                Priority = BehaviorPriority.MediumMediumLast
            };

            b2.FilterCommandCommand = (c) =>
            {
                lastCalled = b2;
                return(commandOutput);
            };



            var sd = new StateDevice(behaviors: new List <BehaviorBase>()
            {
                b1, b2
            });

            sd.Command(primary: CommandType.Off);
            Assert.AreEqual(sd.State.Primary, StateType.On);
            Assert.AreEqual(b2, lastCalled);

            b2.Priority = BehaviorPriority.First;
            sd.Command(primary: CommandType.Off);
            Assert.AreEqual(b1, lastCalled);
        }