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); } }
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); }
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(); } }
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); }