public void AssignReviewer_Fails_NotFound() { var mockSession = new Mock <IDocumentSession>(); var sessionRepo = new Mock <AbstractRepository <ReviewSession> >(mockSession.Object); var eventRepo = new Mock <AbstractRepository <Event> >(mockSession.Object); // Create a new session to work with ReviewSession session = null; sessionRepo.Setup(r => r.Get(It.IsAny <int>())).Returns(session); var manager = new ReviewSessionManager(sessionRepo.Object, eventRepo.Object); Assert.Throws <SessionNotFoundException>(() => manager.AssignReviewer(-1, "*****@*****.**", "*****@*****.**")); }
public void AssignReviewer_Fails_Authorization() { var mockSession = new Mock <IDocumentSession>(); var sessionRepo = new Mock <AbstractRepository <ReviewSession> >(mockSession.Object); var eventRepo = new Mock <AbstractRepository <Event> >(mockSession.Object); // Create a new session to work with var session = NewReviewSession(); sessionRepo.Setup(r => r.Get(It.IsAny <int>())).Returns(session); var manager = new ReviewSessionManager(sessionRepo.Object, eventRepo.Object); Assert.Throws <AuthorizationException>(() => manager.AssignReviewer(session.Id, "*****@*****.**", "FAIL")); }
public void AssignReviewer_Integrates() { // Build the container. var container = Setup(); // Create a new session to work with var session = NewReviewSession(); using (var lifetime = container.BeginLifetimeScope()) { var sessionRepo = lifetime.Resolve <AbstractRepository <ReviewSession> >(); sessionRepo.Save(session); } using (var lifetime = container.BeginLifetimeScope()) { var sessionRepo = lifetime.Resolve <AbstractRepository <ReviewSession> >(); var eventRepo = lifetime.Resolve <AbstractRepository <Event> >(); var manager = new ReviewSessionManager(sessionRepo, eventRepo); Assert.DoesNotThrow(() => manager.AssignReviewer(session.Id, "*****@*****.**", session.Creator)); } using (var lifetime = container.BeginLifetimeScope()) { var sessionRepo = lifetime.Resolve <AbstractRepository <ReviewSession> >(); var eventRepo = lifetime.Resolve <AbstractRepository <Event> >(); var savedSession = sessionRepo.Get(session.Id); Assert.False(savedSession.PendingReviewer); Assert.Equal("*****@*****.**", savedSession.Reviewer); //TODO: Figure out why the build server test break on Event.EventType assertion //var events = eventRepo.ListAll(); //Assert.Equal(1, events.Count); //Assert.Equal(events[0].EventType, EventType.ReviewerInvited); //Assert.Equal(events[0].EntityId, session.Id); } }