Ejemplo n.º 1
0
        public void TestFiltroTag()
        {
            IEventoSismico e = EventoSismicoTest.createMockEvent();

            IFiltroEvento filter = new FiltroTag("Magnitude");

            Assert.IsTrue(filter.Filtra(e));

            IFiltroEvento filter2 = new FiltroTag("Frequency");

            Assert.IsFalse(filter2.Filtra(e));
        }
Ejemplo n.º 2
0
        public void TestFiltroPriorita()
        {
            IFiltroEvento  filter = new FiltroPriorita(Priorita.Info);
            IEventoSismico e      = EventoSismicoTest.createMockEvent();

            // Should be false
            Assert.IsFalse(filter.Filtra(e));

            // Should be true
            IFiltroEvento filter2 = new FiltroPriorita(Priorita.Fatal);

            Assert.IsTrue(filter2.Filtra(e));
        }
Ejemplo n.º 3
0
        public void TestFiltroIntervalloDiTempo()
        {
            IEventoSismico e = EventoSismicoTest.createMockEvent();

            IFiltroEvento filter = new FiltroIntervalloDiTempo(123000, 123999);

            Assert.IsTrue(filter.Filtra(e));

            IFiltroEvento filter2 = new FiltroIntervalloDiTempo(123999, 999999);

            Assert.IsFalse(filter2.Filtra(e));

            IFiltroEvento filter3 = new FiltroIntervalloDiTempo(123000, 123123);

            Assert.IsFalse(filter3.Filtra(e));
        }
Ejemplo n.º 4
0
        public void TestFiltroCerca()
        {
            IEventoSismico e = EventoSismicoTest.createMockEvent();

            // Should be false
            IFiltroEvento filter = new FiltroCerca("yeah");

            Assert.IsFalse(filter.Filtra(e));

            // Should be true
            IFiltroEvento filter2 = new FiltroCerca("BRO");  // Test case insensitive

            Assert.IsTrue(filter2.Filtra(e));

            // Should be true
            IFiltroEvento filter3 = new FiltroCerca("gniTude");  // Test case insensitive

            Assert.IsTrue(filter3.Filtra(e));
        }
Ejemplo n.º 5
0
        public void TestEventManager()
        {
            EventoSismico e = EventoSismicoTest.createMockEvent();

            // Create a mock EventoSismico Repository
            Mock <IStoricoController> eventRepository = new Mock <IStoricoController>();

            GestoreEventi gestoreEventi = new GestoreEventi(eventRepository.Object);

            // Register two event receivers and make sure they are all called
            bool firstReceived  = false;
            bool secondReceived = false;

            gestoreEventi.RicevitoriEventoSismico += (evnt) =>
            {
                // Make sure the received
                Assert.AreEqual(e, evnt);
                firstReceived = true;
            };

            gestoreEventi.RicevitoriEventoSismico += (evnt) =>
            {
                // Make sure the received
                Assert.AreEqual(e, evnt);
                secondReceived = true;
            };

            // Register the event
            gestoreEventi.NotificaEvento(e);

            Assert.IsTrue(firstReceived);
            Assert.IsTrue(secondReceived);

            // Check if the event controller has been called
            eventRepository.Verify(x => x.RegistraEvento(e), Times.Once());
        }