示例#1
0
        public void SaveQuestionnaire_Fails_Not_Found()
        {
            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.SaveQuestionnaire(1, new List <Question>(), "test"));
        }
示例#2
0
        public void SaveQuestionnaire_Fails_Invalid_Status()
        {
            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();

            session.Reviewer      = "*****@*****.**";
            session.SessionStatus = SessionStatusType.Completed;
            sessionRepo.Setup(r => r.Get(It.IsAny <int>())).Returns(session);


            var manager = new ReviewSessionManager(sessionRepo.Object, eventRepo.Object);

            Assert.Throws <InvalidOperationException>(() => manager.SaveQuestionnaire(session.Id, new List <Question>(), session.Reviewer));
        }
示例#3
0
        public void SaveQuestionnaire_Integrates()
        {
            // Build the container.
            var container = Setup();

            // Create a new session to work with
            var session = NewReviewSession();

            session.SessionStatus = SessionStatusType.Released;
            session.Reviewer      = "*****@*****.**";

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

                Mapper.CreateMap <Question, Question>();

                var questions = session.Questions.Select(Mapper.Map <Question>).ToList();

                questions[0].Content = "test was changed";

                Assert.DoesNotThrow(() => manager.SaveQuestionnaire(session.Id, questions, session.Reviewer));
            }

            using (var lifetime = container.BeginLifetimeScope())
            {
                var sessionRepo  = lifetime.Resolve <AbstractRepository <ReviewSession> >();
                var savedSession = sessionRepo.Get(session.Id);

                Assert.Equal(SessionStatusType.Released, savedSession.SessionStatus);
                Assert.Equal(2, savedSession.Questions.Count);
                Assert.Equal("test was changed", savedSession.Questions[0].Content);
            }
        }