public void AddNewEvent()
        {
            MultimodalEngine target = new MultimodalEngine();
            var action = new Mock<ModalityEvent>();

            target.NewInputModalityEvent(action.Object);

            Assert.IsTrue(target.Actions.Contains(action.Object));            
        }
        public void AddOneEffectTrigger()
        {
            MultimodalEngine target = new MultimodalEngine();

            var modalityEvent = new Mock<ModalityEvent>();
            var effect = new Mock<IEffect>();

            EffectTrigger effectTrigger = new EffectTrigger();

            target.addNewTrigger(effectTrigger);

            Assert.IsTrue(target.Triggers.Contains(effectTrigger));
        }
        public void AddOneEffectTriggerAndTriggerIt()
        {
            MultimodalEngine target = new MultimodalEngine();

            ModalityEvent modalityEvent = new ModalityEvent();
            modalityEvent.Type = ActionType.HAND_SWIPE_LEFT;

            var effect = new Mock<IEffect>();

            //Define trigger with one input modality event that triggers one effect
            EffectTrigger effectTrigger = new EffectTrigger();
            effectTrigger.Effects.Add(effect.Object);
            effectTrigger.Triggers.Add(modalityEvent);

            target.addNewTrigger(effectTrigger);

            //Prepare future event
            ModalityEvent action = new ModalityEvent();
            action.Type = ActionType.HAND_SWIPE_LEFT;
            
            //trigger it
            target.NewInputModalityEvent(action);

            //Verify triggering
            effect.Verify(foo => foo.execute());
        }
        public void AVoiceCommandShouldNotTriggerWithoutPostureDirectionTest()
        {
            var mock = new Mock<Clock>();
            var timeInMilliseconds = 0;
            mock.Setup(foo => foo.CurrentTimeInMillis())
                .Returns(() => timeInMilliseconds);

            MultimodalEngine target = new MultimodalEngine();
            target.ClockInstance = mock.Object;

            ModalityEvent modalityEvent1 = new ModalityEvent();
            modalityEvent1.Type = ActionType.POSTURE_DIRECTION_KINECT;

            ModalityEvent modalityEvent2 = new ModalityEvent();
            modalityEvent2.Type = ActionType.SPEECH_NEXT;

            var effect = new Mock<IEffect>();

            //Define trigger with one input modality event that triggers one effect
            EffectTrigger effectTrigger = new EffectTrigger();
            effectTrigger.Effects.Add(effect.Object);
            effectTrigger.Triggers.Add(modalityEvent1);
            effectTrigger.Triggers.Add(modalityEvent2);
            effectTrigger.TimeWindow = 1000;

            target.addNewTrigger(effectTrigger);

            ModalityEvent action2 = new ModalityEvent();
            action2.Type = ActionType.SPEECH_NEXT;
            action2.EventTime = 1500;

            timeInMilliseconds = 1600;
            target.NewInputModalityEvent(action2);

            effect.Verify(foo => foo.execute(), Times.Never());
        }
        public void AddComposedTriggerEffectAndDontTriggerItWithTimeContrainst()
        {
            var mock = new Mock<Clock>();
            var timeInMilliseconds = 0;
            mock.Setup(foo => foo.CurrentTimeInMillis())
                .Returns(() => timeInMilliseconds);

            MultimodalEngine target = new MultimodalEngine();
            target.ClockInstance = mock.Object;

            ModalityEvent modalityEvent1 = new ModalityEvent();
            modalityEvent1.Type = ActionType.HAND_SWIPE_LEFT;

            ModalityEvent modalityEvent2 = new ModalityEvent();
            modalityEvent2.Type = ActionType.HAND_SWIPE_RIGHT;

            var effect = new Mock<IEffect>();

            //Define trigger with one input modality event that triggers one effect
            EffectTrigger effectTrigger = new EffectTrigger();
            effectTrigger.Effects.Add(effect.Object);
            effectTrigger.Triggers.Add(modalityEvent1);
            effectTrigger.Triggers.Add(modalityEvent2);
            effectTrigger.TimeWindow = 1000;

            target.addNewTrigger(effectTrigger);

            //Prepare future event1
            ModalityEvent action1 = new ModalityEvent();
            action1.Type = ActionType.HAND_SWIPE_LEFT;
            action1.EventTime = 1000;

            timeInMilliseconds = 1001;
            target.NewInputModalityEvent(action1);

            //Was not trigger yet
            effect.Verify(foo => foo.execute(), Times.Never());

            //Prepare future event2
            ModalityEvent action2 = new ModalityEvent();
            action2.Type = ActionType.HAND_SWIPE_RIGHT;
            action2.EventTime = 3001;

            timeInMilliseconds = 3001;
            target.NewInputModalityEvent(action2);

            effect.Verify(foo => foo.execute(), Times.Never());
        }
        public void AddOneEffectTriggerAndDontTriggerItTimeHasPassed()
        {
            var mock = new Mock<Clock>();
            var timeInMilliseconds = 0;
            mock.Setup(foo => foo.CurrentTimeInMillis())
                .Returns(() => timeInMilliseconds);

            MultimodalEngine target = new MultimodalEngine();
            target.ClockInstance = mock.Object;

            ModalityEvent modalityEvent = new ModalityEvent();
            modalityEvent.Type = ActionType.HAND_SWIPE_LEFT;

            var effect = new Mock<IEffect>();

            //Define trigger with one input modality event that triggers one effect
            EffectTrigger effectTrigger = new EffectTrigger();
            effectTrigger.Effects.Add(effect.Object);
            effectTrigger.Triggers.Add(modalityEvent);
            effectTrigger.TimeWindow = 1000;

            target.addNewTrigger(effectTrigger);

            //Prepare future event
            ModalityEvent action = new ModalityEvent();
            action.Type = ActionType.HAND_SWIPE_LEFT;
            action.EventTime = 1000;

            //trigger it
            timeInMilliseconds = 3000;
            target.NewInputModalityEvent(action);

            //Verify triggering
            effect.Verify(foo => foo.execute(), Times.Never());
        }
        public void AddOneTriggerAndTriggersOnCorrectTimePassed()
        {            
            MultimodalEngine target = new MultimodalEngine();
            
            ModalityEvent modalityEvent = new ModalityEvent();
            modalityEvent.Type = ActionType.HAND_SWIPE_LEFT;

            var effect = new Mock<IEffect>();

            //Define trigger with one input modality event that triggers one effect
            EffectTrigger effectTrigger = new EffectTrigger();
            effectTrigger.Effects.Add(effect.Object);
            effectTrigger.Triggers.Add(modalityEvent);

            target.addNewTrigger(effectTrigger);

            //Prepare future event
            ModalityEvent action = new ModalityEvent();
            action.Type = ActionType.HAND_SWIPE_RIGHT;

            //add event
            target.NewInputModalityEvent(action);
        }
        public void AddComposedTriggerEffectAndTriggerIt()
        {
            MultimodalEngine target = new MultimodalEngine();

            ModalityEvent modalityEvent1 = new ModalityEvent();
            modalityEvent1.Type = ActionType.HAND_SWIPE_LEFT;

            ModalityEvent modalityEvent2 = new ModalityEvent();
            modalityEvent2.Type = ActionType.HAND_SWIPE_RIGHT;

            var effect = new Mock<IEffect>();

            //Define trigger with one input modality event that triggers one effect
            EffectTrigger effectTrigger = new EffectTrigger();
            effectTrigger.Effects.Add(effect.Object);
            effectTrigger.Triggers.Add(modalityEvent1);
            effectTrigger.Triggers.Add(modalityEvent2);

            target.addNewTrigger(effectTrigger);

            //Prepare future event1
            ModalityEvent action1 = new ModalityEvent();
            action1.Type = ActionType.HAND_SWIPE_LEFT;
            action1.EventTime = 1000;

            target.NewInputModalityEvent(action1);

            //Was not trigger yet
            effect.Verify(foo => foo.execute(), Times.Never());

            //Prepare future event2
            ModalityEvent action2 = new ModalityEvent();
            action2.Type = ActionType.HAND_SWIPE_RIGHT;

            target.NewInputModalityEvent(action2);

            effect.Verify(foo => foo.execute());
        }