Exemplo n.º 1
0
        public void SilentAlarm_WhenTurnedOff_CanAlertSecurityAgain()
        {
            var sut = new SilentAlarm(_events);
            var timesSecurityCalled = 0;

            _events.Subscribe <AlertSecurityEvent>(e => timesSecurityCalled++);

            sut.Trigger(new XY());
            sut.TurnOff();
            sut.Trigger(new XY());

            Assert.AreEqual(2, timesSecurityCalled);
        }
Exemplo n.º 2
0
        public void SilentAlarm_Triggered_FiresAlertEvent()
        {
            var sut     = new SilentAlarm(_events);
            var alerted = false;

            _events.Subscribe <AlertSecurityEvent>(e => alerted = true);

            sut.Trigger(new XY());

            Assert.IsTrue(alerted);
        }
Exemplo n.º 3
0
        public void SilentAlarm_Disarmed_TriggerDoesNothing()
        {
            var sut     = new SilentAlarm(_events);
            var alerted = false;

            _events.Subscribe <AlertSecurityEvent>(e => alerted = true);

            sut.Disarm();
            sut.Trigger(new XY());

            Assert.IsFalse(alerted);
        }
Exemplo n.º 4
0
        public void SilentAlarm_TriggeredMultipleTimes_OnlyCallsSecurityOnce()
        {
            var sut = new SilentAlarm(_events);
            var timesSecurityCalled = 0;

            _events.Subscribe <AlertSecurityEvent>(e => timesSecurityCalled++);

            foreach (var _ in Enumerable.Range(0, 5))
            {
                sut.Trigger(new XY());
            }

            Assert.AreEqual(1, timesSecurityCalled);
        }