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