public void CancelEventNoMatchingRecordsReturnInvalidEventIdException() { Guid userId = Guid.NewGuid(); Guid eventId = Guid.NewGuid(); EventRepositoryMock <ScheduledEvent> .ListOfEvents = new List <IEvent>(); UserRepositoryMock <User> .ThrowException = false; EventRepositoryMock <ScheduledEvent> .ThrowException = false; try { using (UserFacade facade = new UserFacade()) { facade.CancelEvent(userId, eventId); } } catch (InvalidEventIdException) { Assert.Pass(); } catch (Exception ex) { Assert.Fail("Unexpected exception happened while testing CancelEvent. Exception: {0}", ex.Message); } Assert.Fail("An InvalidEventIdException should have been thrown"); }
public void CancelEventSuccessfulReturnNothing() { Guid userId = Guid.NewGuid(); Guid eventId = Guid.NewGuid(); EventRepositoryMock <ScheduledEvent> .OwnerId = userId; var evtList = new List <IEvent>(); evtList.Add(new ScheduledEvent() { ID = eventId, Name = "Test Event", Time = "2015-05-24T17:02:39Z", Active = true }); EventRepositoryMock <ScheduledEvent> .ListOfEvents = evtList; UserRepositoryMock <User> .ThrowException = false; EventRepositoryMock <ScheduledEvent> .ThrowException = false; try { using (UserFacade facade = new UserFacade()) { facade.CancelEvent(userId, eventId); } } catch (Exception ex) { Assert.Fail("Unexpected exception happened while testing CancelEvent. Exception: {0}", ex.Message); } Assert.Pass(); }
//Update Contacts attendents status public APIResponse Post(Guid userId, Guid eventId, EventAttendantsStatus attendStatus) { try { if (attendStatus == EventAttendantsStatus.Cancel) { using (UserFacade userFacade = new UserFacade()) userFacade.CancelEvent(userId, eventId); APIResponse response = new APIResponse(APIResponse.ReponseStatus.success, null); return(response); } else { using (EventFacade eventFacade = new EventFacade()) eventFacade.ChangeContactAttendanceStatus(userId, eventId, attendStatus); APIResponse response = new APIResponse(APIResponse.ReponseStatus.success, null); return(response); } } catch (Exception ex) { APIResponse response = new APIResponse(APIResponse.ReponseStatus.error, new { Error = ex.Message }); return(response); } }
public void CancelEventEventIdAsNinesReturnInvalidEventIdException() { Guid userId = Guid.NewGuid(); Guid eventId = new Guid("99999999-9999-9999-9999-999999999999"); try { using (UserFacade facade = new UserFacade()) { facade.CancelEvent(userId, eventId); } } catch (InvalidEventIdException) { Assert.Pass(); } catch (Exception ex) { Assert.Fail("Unexpected exception happened while testing CancelEvent. Exception: {0}", ex.Message); } Assert.Fail("An InvalidEventIdException should have been thrown"); }
public void CancelEventEventNotActiveReturnEventException() { Guid userId = Guid.NewGuid(); Guid eventId = Guid.NewGuid(); EventRepositoryMock <ScheduledEvent> .OwnerId = userId; var evtList = new List <IEvent>(); evtList.Add(new ScheduledEvent() { ID = eventId, Name = "Test Event", Active = false }); EventRepositoryMock <ScheduledEvent> .ListOfEvents = evtList; UserRepositoryMock <User> .ThrowException = false; EventRepositoryMock <ScheduledEvent> .ThrowException = false; try { using (UserFacade facade = new UserFacade()) { facade.CancelEvent(userId, eventId); } } catch (EventException) { Assert.Pass(); } catch (Exception ex) { Assert.Fail("Unexpected exception happened while testing CancelEvent. Exception: {0}", ex.Message); } Assert.Fail("An InvalidEventIdException should have been thrown"); }