Beispiel #1
0
        public void FindEventPassingEventIdAsNinesReturnNullEvent()
        {
            IEvent evt = new ScheduledEvent()
            {
                ID = new Guid("99999999-9999-9999-9999-999999999999"), Name = "Test Update", Active = true
            };
            List <IEvent> eventList = new List <IEvent>();

            eventList.Add(evt);

            EventRepositoryMock <ScheduledEvent> .ThrowException = false;
            EventRepositoryMock <ScheduledEvent> .ListOfEvents   = eventList;
            IEvent result = new ScheduledEvent();


            try
            {
                using (EventFacade facade = new EventFacade())
                {
                    result = facade.FindEvent(EventRepositoryMock <ScheduledEvent> .EventId);
                }
                Assert.Fail("Expecting to receive an InvalidEventId Exception.");
            }
            catch (InvalidEventIdException)
            {
                Assert.Pass();
            }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception escaped call to FindEvent method in the EventFacade. Exception: {1}", ex.Message);
            }
        }
Beispiel #2
0
        public void FindEventPassingValidEventIdThatExistReturnEvent()
        {
            IEvent evt = new ScheduledEvent()
            {
                ID = Guid.NewGuid(), Name = "Test Update", Active = true
            };
            List <IEvent> eventList = new List <IEvent>();

            eventList.Add(evt);

            EventRepositoryMock <ScheduledEvent> .ThrowException = false;
            EventRepositoryMock <ScheduledEvent> .ListOfEvents   = eventList;
            IEvent result = new ScheduledEvent();


            try
            {
                using (EventFacade facade = new EventFacade())
                {
                    result = facade.FindEvent(evt.ID);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception escaped call to FindEvent method in the EventFacade. Exception: {0}", ex.Message);
            }
            Assert.AreEqual(evt, result);
        }
Beispiel #3
0
        public void FindEventWhenRepositoryExceptionHappensReturningNullEvent()
        {
            IEvent evt = new ScheduledEvent()
            {
                ID = Guid.NewGuid(), Name = "Test Update", Active = true
            };
            List <IEvent> eventList = new List <IEvent>();

            eventList.Add(evt);

            EventRepositoryMock <ScheduledEvent> .ThrowException = true;
            EventRepositoryMock <ScheduledEvent> .ListOfEvents   = eventList;
            IEvent result = new ScheduledEvent();


            try
            {
                using (EventFacade facade = new EventFacade())
                {
                    result = facade.FindEvent(evt.ID);
                }
                Assert.Fail("Exception from repository should be allow to bubble up");
            }
            catch (Exception)
            {
                Assert.Pass();
            }
        }
Beispiel #4
0
        public void FindEventPassingValidEventIdThatNotExistReturnNullEvent()
        {
            List <IEvent> eventList = new List <IEvent>();

            EventRepositoryMock <ScheduledEvent> .ThrowException = false;
            EventRepositoryMock <ScheduledEvent> .ListOfEvents   = eventList;
            IEvent result = new ScheduledEvent();


            try
            {
                using (EventFacade facade = new EventFacade())
                {
                    result = facade.FindEvent(Guid.NewGuid());
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception escaped call to FindEvent method in the EventFacade. Exception: {0}", ex.Message);
            }

            Assert.AreEqual(null, result);
        }