public void Details_ReturnsA404_WhenTheUserCannotBeFound()
        {
            var sessionRepository = Substitute.For<ISessionRepository>();
            var voteRepository = Substitute.For<IVoteRepository>();
            var controller = new SessionController(sessionRepository, voteRepository);

            var actionResult = controller.Details(123);

            Assert.That(actionResult.GetHttpStatusCode(), Is.EqualTo(HttpStatusCode.NotFound));
        }
        public void DeleteConfirmed_DeletesTheCorrectUser()
        {
            var sessionRepository = Substitute.For<ISessionRepository>();
            var voteRepository = Substitute.For<IVoteRepository>();
            var controller = new SessionController(sessionRepository, voteRepository);

            controller.DeleteConfirmed(123);

            sessionRepository.Received().DeleteSession(123);
        }
        public void Details_GetsTheCorrectSessionDetails()
        {
            const int sessionId = 123;
            var sessionRepository = Substitute.For<ISessionRepository>();
            sessionRepository.Get(sessionId).Returns(new Session {SessionId = sessionId});
            var voteRepository = Substitute.For<IVoteRepository>();
            var controller = new SessionController(sessionRepository, voteRepository);

            var actionResult = controller.Details(sessionId);

            var model = actionResult.GetViewModel<Session>();
            Assert.That(model.SessionId, Is.EqualTo(sessionId));
        }
        public void Edit_DoesNotSaveTheUserProfile_WhenTheSubmittedDataIsInvalid()
        {
            var sessionRepository = Substitute.For<ISessionRepository>();
            var voteRepository = Substitute.For<IVoteRepository>();
            var controller = new SessionController(sessionRepository, voteRepository);
            controller.CreateModelStateError();

            controller.Edit(new Session());

            sessionRepository.DidNotReceive().UpdateSession(Arg.Any<Session>());
        }
        public void Edit_SavesTheUserProfileCorrectly()
        {
            var sessionRepository = Substitute.For<ISessionRepository>();
            var voteRepository = Substitute.For<IVoteRepository>();
            var controller = new SessionController(sessionRepository, voteRepository);
            var session = new Session { Title = "A session", Abstract = "My session is about...", SpeakerUserName = "******" };

            controller.Edit(session);

            sessionRepository.Received().UpdateSession(session);
        }