Exemplo n.º 1
0
        public void RenderWithNoCourse()
        {
            string loginName = Environment.UserDomainName + "\\" + Environment.UserName;
            string courseId  = "999999";

            MockCourseRegistrationView mockView = new MockCourseRegistrationView();

            mockView.QueryString       = new System.Collections.Specialized.NameValueCollection();
            mockView.QueryString["ID"] = courseId;

            MockTrainingCourseRepository.TrainingCourseReturnedByGet = null;

            this.serviceLocator.Register <ITrainingCourseRepository>(typeof(MockTrainingCourseRepository));

            CourseRegistrationPresenter presenter = new CourseRegistrationPresenter(mockView);

            presenter.RenderCourseRegistrationView(web, loginName);

            Assert.AreEqual <string>("Course Registration - Failure", mockView.PageTitle);
            Assert.AreEqual <string>("Course Registration", mockView.HeaderTitle);
            Assert.AreEqual <string>("Failure", mockView.HeaderSubtitle);
            Assert.AreEqual <string>("The Course selected was not a valid.", mockView.ContentMessage);
            Assert.AreEqual(web.Url, mockView.SiteLink);
            Assert.IsFalse(mockView.ShowConfirmationControls);
            Assert.IsFalse(mockView.ShowCourseSelectionControls);
        }
Exemplo n.º 2
0
        public void RenderCourseRegistrationPopulatesView()
        {
            string loginName = Environment.UserDomainName + "\\" + Environment.UserName;

            string courseId = "1";

            MockCourseRegistrationView mockView = new MockCourseRegistrationView();

            mockView.QueryString       = new System.Collections.Specialized.NameValueCollection();
            mockView.QueryString["ID"] = courseId;

            TrainingCourse course = new TrainingCourse()
            {
                Id = 1, Code = "TestCode"
            };

            MockTrainingCourseRepository.TrainingCourseReturnedByGet = course;

            this.serviceLocator.Register <IRegistrationRepository>(typeof(MockRegistrationRepository));
            this.serviceLocator.Register <ITrainingCourseRepository>(typeof(MockTrainingCourseRepository));

            CourseRegistrationPresenter presenter = new CourseRegistrationPresenter(mockView);

            presenter.RenderCourseRegistrationView(web, loginName);

            Assert.AreEqual <string>("Course Registration - TestCode", mockView.PageTitle);
            Assert.AreEqual <string>("Course Registration", mockView.HeaderTitle);
            Assert.AreEqual <string>("TestCode", mockView.HeaderSubtitle);
            Assert.AreEqual <string>("Would you like to register for course: TestCode?", mockView.ContentMessage);
            Assert.IsTrue(mockView.ShowConfirmationControls);
            Assert.IsFalse(mockView.ShowCourseSelectionControls);
            Assert.AreEqual(web.Url, mockView.SiteLink);
        }
Exemplo n.º 3
0
        public void RenderCourseRegistrationPopulatesView()
        {
            string loginName = @"domain\alias";
            string courseId  = "1";
            SPWeb  mockWeb   = CreateMockSPWeb(false);

            MockCourseRegistrationView mockView = new MockCourseRegistrationView();

            mockView.QueryString       = new System.Collections.Specialized.NameValueCollection();
            mockView.QueryString["ID"] = courseId;

            TrainingCourse course = new TrainingCourse()
            {
                Id = 1, Code = "TestCode"
            };

            MockTrainingCourseRepository.TrainingCourseReturnedByGet = course;

            this.serviceLocator.Register <IRegistrationRepository>(typeof(MockRegistrationRepository));
            this.serviceLocator.Register <ITrainingCourseRepository>(typeof(MockTrainingCourseRepository));

            CourseRegistrationPresenter presenter = new CourseRegistrationPresenter(mockView);

            presenter.RenderCourseRegistrationView(mockWeb, loginName);

            Assert.AreEqual <string>("Course Registration - TestCode", mockView.PageTitle);
            Assert.AreEqual <string>("Course Registration", mockView.HeaderTitle);
            Assert.AreEqual <string>("TestCode", mockView.HeaderSubtitle);
            Assert.AreEqual <string>("Would you like to register for course: TestCode?", mockView.ContentMessage);
            Assert.IsTrue(mockView.ShowConfirmationControls);
            Assert.IsFalse(mockView.ShowCourseSelectionControls);
            Assert.AreEqual("http://localhost/training", mockView.SiteLink);
            MockManager.Verify();
        }
Exemplo n.º 4
0
        public void RenderWithNoCourse()
        {
            string loginName = @"domain\alias";
            string courseId  = "999999";
            SPWeb  mockWeb   = CreateMockSPWeb(true);

            MockCourseRegistrationView mockView = new MockCourseRegistrationView();

            mockView.QueryString       = new System.Collections.Specialized.NameValueCollection();
            mockView.QueryString["ID"] = courseId;

            MockTrainingCourseRepository.TrainingCourseReturnedByGet = null;

            this.serviceLocator.Register <ITrainingCourseRepository>(typeof(MockTrainingCourseRepository));

            CourseRegistrationPresenter presenter = new CourseRegistrationPresenter(mockView);

            presenter.RenderCourseRegistrationView(mockWeb, loginName);

            Assert.AreEqual <string>("Course Registration - Failure", mockView.PageTitle);
            Assert.AreEqual <string>("Course Registration", mockView.HeaderTitle);
            Assert.AreEqual <string>("Failure", mockView.HeaderSubtitle);
            Assert.AreEqual <string>("The Course selected was not a valid.", mockView.ContentMessage);
            Assert.AreEqual("http://localhost/training", mockView.SiteLink);
            Assert.IsFalse(mockView.ShowConfirmationControls);
            Assert.IsFalse(mockView.ShowCourseSelectionControls);
            MockManager.Verify();
        }
Exemplo n.º 5
0
        public void RenderCourseRegistrationPopulatesViewWithCourseSelectionList()
        {
            string loginName = @"domain\alias";
            SPWeb  mockWeb   = this.CreateMockSPWeb(true);

            MockCourseRegistrationView mockView = new MockCourseRegistrationView();

            mockView.QueryString = new System.Collections.Specialized.NameValueCollection();

            TrainingCourse course = new TrainingCourse()
            {
                Id   = 1,
                Code = "TestCode"
            };

            MockTrainingCourseRepository.TrainingCourseReturnedByGet = course;
            List <TrainingCourse> courses = new List <TrainingCourse>();
            TrainingCourse        course1 = new TrainingCourse()
            {
                Id   = 1,
                Code = "TstCode1"
            };
            TrainingCourse course2 = new TrainingCourse()
            {
                Id   = 2,
                Code = "TstCode2"
            };

            courses.Add(course1);
            courses.Add(course2);
            MockTrainingCourseRepository.TrainingCourseListReturnedByGet = courses;

            this.serviceLocator.Register <IRegistrationRepository>(typeof(MockRegistrationRepository));
            this.serviceLocator.Register <ITrainingCourseRepository>(typeof(MockTrainingCourseRepository));

            CourseRegistrationPresenter presenter = new CourseRegistrationPresenter(mockView);

            presenter.RenderCourseRegistrationView(mockWeb, loginName);

            Assert.AreEqual <string>("Course Registration", mockView.HeaderTitle);
            Assert.AreEqual <string>("Course Registration - New", mockView.PageTitle);
            Assert.AreEqual <string>("New", mockView.HeaderSubtitle);
            Assert.AreEqual <string>("Which course would you like to register for?", mockView.ContentMessage);
            Assert.IsNotNull(mockView.Courses);
            Assert.AreEqual(2, mockView.Courses.Count);
            Assert.AreEqual("TstCode1", mockView.Courses[0].Code);
            Assert.AreEqual("TstCode2", mockView.Courses[1].Code);
            Assert.IsTrue(mockView.ShowConfirmationControls);
            Assert.IsTrue(mockView.ShowCourseSelectionControls);
            Assert.AreEqual("http://localhost/training", mockView.SiteLink);
            MockManager.Verify();
        }
Exemplo n.º 6
0
        public void RegisterCourseAndPopulateConfirmationWithSelectedCourse()
        {
            string loginName = @"domain\alias";
            string courseId  = "1";
            SPWeb  mockWeb   = CreateMockSPWeb(false);

            MockCourseRegistrationView mockView = new MockCourseRegistrationView();

            mockView.QueryString    = new System.Collections.Specialized.NameValueCollection();
            mockView.SelectedCourse = courseId;

            MockRegistrationRepository.RegistrationReturnedByGet = null;

            TrainingCourse course = new TrainingCourse()
            {
                Id    = 1,
                Title = "TestTitle",
                Code  = "TestCode"
            };

            MockTrainingCourseRepository.TrainingCourseReturnedByGet = course;

            this.serviceLocator.Register <IRegistrationRepository>(typeof(MockRegistrationRepository));
            this.serviceLocator.Register <ITrainingCourseRepository>(typeof(MockTrainingCourseRepository));

            CourseRegistrationPresenter presenter = new CourseRegistrationPresenter(mockView);

            presenter.Register(mockWeb, loginName);

            Assert.AreEqual(@"TestCode - domain\alias", MockRegistrationRepository.RegistrationReturnedByGet.Title);
            Assert.AreEqual(1, MockRegistrationRepository.RegistrationReturnedByGet.UserId);
            Assert.AreEqual(1, MockRegistrationRepository.RegistrationReturnedByGet.CourseId);
            Assert.AreEqual("Pending", MockRegistrationRepository.RegistrationReturnedByGet.RegistrationStatus);
            Assert.AreEqual <string>("Course Registration - TestCode", mockView.PageTitle);
            Assert.AreEqual <string>("Course Registration", mockView.HeaderTitle);
            Assert.AreEqual <string>("TestCode", mockView.HeaderSubtitle);
            Assert.AreEqual <string>("Your registration request for TestCode has been submitted.", mockView.ContentMessage);
            Assert.AreEqual("http://localhost/training", mockView.SiteLink);
            Assert.IsFalse(mockView.ShowConfirmationControls);
            Assert.IsFalse(mockView.ShowCourseSelectionControls);
            MockManager.Verify();
        }
Exemplo n.º 7
0
        public void RenderWithExistingRegistration()
        {
            string loginName = @"domain\alias";
            string courseId  = "1";
            SPWeb  mockWeb   = CreateMockSPWeb(false);

            MockCourseRegistrationView mockView = new MockCourseRegistrationView();

            mockView.QueryString       = new System.Collections.Specialized.NameValueCollection();
            mockView.QueryString["ID"] = courseId;

            TrainingCourse course = new TrainingCourse()
            {
                Id = 1, Code = "TestCode"
            };

            MockTrainingCourseRepository.TrainingCourseReturnedByGet = course;

            Registration registration = new Registration();

            registration.RegistrationStatus = "Pending";
            MockRegistrationRepository.RegistrationReturnedByGet = registration;

            this.serviceLocator.Register <IRegistrationRepository>(typeof(MockRegistrationRepository));
            this.serviceLocator.Register <ITrainingCourseRepository>(typeof(MockTrainingCourseRepository));

            CourseRegistrationPresenter presenter = new CourseRegistrationPresenter(mockView);

            presenter.RenderCourseRegistrationView(mockWeb, loginName);

            Assert.AreEqual <string>("Course Registration - TestCode", mockView.PageTitle);
            Assert.AreEqual <string>("Course Registration", mockView.HeaderTitle);
            Assert.AreEqual <string>("TestCode", mockView.HeaderSubtitle);
            Assert.AreEqual <string>("A registration request for this Course with the status of 'Pending' has already been submitted by you.", mockView.ContentMessage);
            Assert.AreEqual("http://localhost/training", mockView.SiteLink);
            Assert.IsFalse(mockView.ShowConfirmationControls);
            Assert.IsFalse(mockView.ShowCourseSelectionControls);
            MockManager.Verify();
        }