Example #1
0
        public void RegisterCourseAndPopulateConfirmation()
        {
            string loginName = Environment.UserDomainName + "\\" + Environment.UserName;
            string courseId  = "1";

            MockCourseRegistrationView mockView = new MockCourseRegistrationView();

            mockView.QueryString       = new System.Collections.Specialized.NameValueCollection();
            mockView.QueryString["ID"] = 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(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>("Your registration request for TestCode has been submitted.", mockView.ContentMessage);
            Assert.AreEqual(web.Url, mockView.SiteLink);
            Assert.IsFalse(mockView.ShowConfirmationControls);
            Assert.IsFalse(mockView.ShowCourseSelectionControls);
        }
Example #2
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();
        }