Пример #1
0
        public void Edit_Integrates()
        {
            // Build the container.
            var container = Setup();

            var session = NewReviewSession();

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

                // Create a new session to work with
                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);

                AutoMapper.Mapper.CreateMap <ReviewSession, ReviewSession>();
                var editSession = AutoMapper.Mapper.Map <ReviewSession>(session);

                editSession.Requirements.Add(new Requirement {
                    Comment = "test", Content = "test"
                });

                Assert.DoesNotThrow(() => manager.Edit(editSession, session.Creator));
            }
        }
        public void Edit_Fails_UnAuthorized()
        {
            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.Edit(session, "FAIL"));
        }
        public void Edit_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.SessionStatus = SessionStatusType.Released;
            sessionRepo.Setup(r => r.Get(It.IsAny <int>())).Returns(session);

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

            Assert.Throws <InvalidOperationException>(() => manager.Edit(session, session.Creator));
        }