public void GetCourses_Modality_Online_Success() { using (OdsRepository repository = new OdsRepository()) { IList <ISectionFacet> facets = TestHelper.GetFacets(new ModalityFacet(ModalityFacet.Options.Online)); IList <Course> courses = repository.GetCourses(facets); Debug.Print("==> Online course count before DISTINCT: {0}", courses.Count); int count = courses.Select(c => c.CourseID).Distinct().Count(); Debug.Print("==> Online course count after DISTINCT: {0}", count); #if DEBUG foreach (string courseid in courses.Select(c => c.CourseID).Distinct()) { Debug.Print(courseid); } #endif int expectedCount = _dataVerifier.GetCourseIDCountForSections(String.Format("SBCTCMisc1 like '3%'")); Assert.AreEqual(expectedCount, count); int allCount = _dataVerifier.GetCourseIDCountForSections("not ClassID is null"); Assert.IsTrue(allCount > count, "Online course count is not less than count of all courses."); } }
// [Ignore] // NOTE: Proper implementation requires restructuring the GetCourses() calls. See Task #16. public void CourseFootnotes_Success() { using (OdsRepository repository = new OdsRepository()) { IList <Course> courses = repository.GetCourses(); // IList<Course> courses = repository.GetCourses("engl"); Assert.IsTrue(courses.Count > 0, "No courses returned"); #if DEBUG Debug.Print("==== All courses returned ({0}) ====", courses.Count); foreach (Course course in courses) { Debug.Print("{0}", course.CourseID); } #endif IEnumerable <Course> withFootnotes = courses.Where(c => c.Footnotes.Count > 0); #if DEBUG Debug.Print("==== Courses with footnotes ({0}) ====", withFootnotes.Count()); foreach (Course course in withFootnotes) { Debug.Print("{0}\t({1})", course.CourseID, course.Footnotes.Count); } #endif int actual = withFootnotes.Count(); int expected = _dataVerifier.GetCourseCount("((FootnoteID1 IN (SELECT f.footnoteid FROM dbo.vw_Footnote f) or FootnoteID2 IN (SELECT f.FootnoteID FROM dbo.vw_Footnote f)))"); // int expected = _dataVerifier.GetCourseCount("(isnull(FootnoteID1, '') <> '' or ISNULL(FootnoteID2, '') <> '') and rtrim(left(replace(CourseID, '&', ' '), 5)) = 'engl'"); Assert.AreEqual(expected, actual); } }
public void GetCourses_VerifyCcnFlag_False() { using (OdsRepository repository = new OdsRepository()) { IList <Course> courses = repository.GetCourses(); Course course = courses.Where(s => !(s.Subject.EndsWith("&"))).Take(1).Single(); Assert.IsFalse(course.IsCommonCourse); } }
public void GetCourses_VerifyCcnFlag_True() { using (OdsRepository repository = new OdsRepository()) { IList <Course> courses = repository.GetCourses(); int expectedCount = _dataVerifier.GetCourseCount("CourseID like '%&%'"); Assert.AreEqual(expectedCount, courses.Where(c => c.IsCommonCourse).Count()); } }
public void GetCourses_VerifyCommonCourseCharacterRemovedFromCourseID() { using (OdsRepository repository = new OdsRepository()) { IList <Course> courses = repository.GetCourses("CHEM"); int count = courses.Where(s => s.CourseID.Contains("&")).Count(); Assert.IsTrue(count == 0, "{0} records found to still contain the CCN character ('&') in the CourseID", count); } }
/// <summary> /// /// </summary> /// <param name="subject"></param> private void AssertCourseCount(string subject) { using (OdsRepository repository = new OdsRepository()) { IList <Course> courses = repository.GetCourses(subject); Assert.IsTrue(courses.Count > 0, "No records were returned for '{0}'!", subject); AssertCourseCount(courses, string.Format("rtrim(LEFT(CourseID, 5)) = '{0}'", subject)); } }
public void GetCourses_VerifyCommonCourseCharacterRemovedFromCourseID() { using (OdsRepository repository = new OdsRepository()) { IList<Course> courses = repository.GetCourses("CHEM"); int count = courses.Where(s => s.CourseID.Contains("&")).Count(); Assert.IsTrue(count == 0, "{0} records found to still contain the CCN character ('&') in the CourseID", count); } }
public void GetCourses_Success() { int count; using (OdsRepository repository = new OdsRepository()) { count = repository.GetCourses().Count(); } Assert.IsTrue(count > 0); }
/// <summary> /// /// </summary> /// <param name="subject"></param> /// <param name="number"></param> private void AssertCourseCount(string subject, string number) { using (OdsRepository repository = new OdsRepository()) { ICourseID courseID = CourseID.FromString(subject, number); IList <Course> courses = repository.GetCourses(courseID); Assert.IsTrue(courses.Count > 0, "No records were returned for '{0} {1}'!", subject, number); AssertCourseCount(courses, string.Format("rtrim(LEFT(CourseID, 5)) = '{0}' and LTRIM(RTRIM(SUBSTRING(CourseID, 6, 5))) = '{1}'", subject, number)); } }
[Ignore] // specific research, not part of the standard test suite public void Research() { using (OdsRepository repository = new OdsRepository()) { string courseId = "CEO 196"; IList <Course> courses = repository.GetCourses(CourseID.FromString(courseId)); Assert.IsTrue(courses.Count > 0); var foo = courses.Select(c => c.CourseID); Assert.AreEqual(courses.Count, courses.Count(c => c.CourseID == courseId)); } }
public void GetCourses_ByCourseID_Success() { using (OdsRepository repository = new OdsRepository()) { IEnumerable <ICourse> courses = repository.GetCourses(CourseID.FromString("art 101")); Assert.IsNotNull(courses); int allCoursesCount = courses.Count(); Assert.IsTrue(allCoursesCount > 0); int filteredCourseCount = courses.Where(c => Regex.IsMatch(c.CourseID.ToUpper(), @"ART\s+101")).Count(); Assert.AreEqual(allCoursesCount, filteredCourseCount); } }
public void GetCourses_VerifyIsVariableCredit() { using (OdsRepository repository = new OdsRepository()) { IList <string> subjects = new List <string> { "ENGL", "ENGL&" }; IList <Course> courses = repository.GetCourses(subjects); Assert.IsTrue(courses.Count > 0); int count = _dataVerifier.GetCourseCount("(rtrim(left(CourseID, 5)) = 'ENGL' or rtrim(left(CourseID, 5)) = 'ENGL&') AND isnull(VariableCredits, 0) = 1"); Assert.AreEqual(count, courses.Where(c => c.IsVariableCredits).Count()); } }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="repository"></param> private void VerifyModalityTimes(string start, string end, OdsRepository repository) { TimeSpan startTime = TimeSpan.Parse(start); TimeSpan endTime = TimeSpan.Parse(end); IList <ISectionFacet> facets = TestHelper.GetFacets(new TimeFacet(startTime, endTime)); int count = repository.GetCourses(facets).Select(c => c.CourseID).Distinct().Count(); Assert.IsTrue(count > 0, "No sections were returned"); int allCount = _dataVerifier.GetCourseIDCountForSections("not ClassID is null"); Assert.IsTrue(allCount > count, "Filtered course count ({0}) is not less than count of all courses ({1}).", count, allCount); }
public void GetCourses_Modality_OnCampus_Success() { using (OdsRepository repository = new OdsRepository()) { IList <ISectionFacet> facets = TestHelper.GetFacets(new ModalityFacet(ModalityFacet.Options.OnCampus)); int count = repository.GetCourses(facets).Select(c => c.CourseID).Distinct().Count(); int expectedCount = _dataVerifier.GetCourseIDCountForSections(String.Format("isnull(SBCTCMisc1, '') not like '3%' and isnull(SBCTCMisc1, '') not like '8%' and isnull(SBCTCMisc1, '') not like '1%'")); Assert.AreEqual(expectedCount, count); int allCount = _dataVerifier.GetCourseIDCountForSections("not ClassID is null"); Assert.IsTrue(allCount > count, "Online course count is not less than count of all courses."); } }
public void GetCourses_VerifySortedByCourseID() { using (OdsRepository repository = new OdsRepository()) { IList <Course> courses = repository.GetCourses("CHEM"); string prevCourseID = " "; // TODO: is there a more efficient way to determine that the whole list is sorted? foreach (Course course in courses) { string thisCourseID = course.CourseID; Assert.IsTrue(thisCourseID.CompareTo(prevCourseID) >= 0, "Invalid order found: [{0}] is not less than [{1}]", prevCourseID, thisCourseID); prevCourseID = thisCourseID; } } }
public void GetCourses_WithDescription_Success() { using (OdsRepository repository = new OdsRepository()) { IList <Course> courses = repository.GetCourses(); int allCount = courses.Count; Assert.IsTrue(allCount > 0, "No courses found."); IEnumerable <Course> withNonNullDesc = courses.Where(c => c.Descriptions != null); Assert.IsTrue(withNonNullDesc.Count() > 0, "All Descriptions properties are null"); // TODO: resolve issues with some courses not having descriptions //IEnumerable<Course> withDescCounts = withNonNullDesc.Where(d => d.Descriptions.Count() > 0); ////IEnumerable<Course> withoutDescCounts = withNonNullDesc.Where(d => d.Descriptions.Count() <= 0); //Assert.AreEqual(allCount, withDescCounts.Count(), "{0} (out of {1}) Courses missing description entries", allCount - withDescCounts.Count(), allCount); } }
/// <summary> /// /// </summary> /// <param name="subjects"></param> private void AssertCourseCount(IList <string> subjects) { using (OdsRepository repository = new OdsRepository()) { IList <Course> courses = repository.GetCourses(subjects); Assert.IsTrue(courses.Count > 0, "No records were returned for '{0}'!", subjects); string whereClause = string.Empty; if (subjects.Count > 0) { whereClause = "("; for (int i = 0; i < subjects.Count; i++) { whereClause = string.Concat(whereClause, i > 0 ? " or " : string.Empty, String.Format("rtrim(LEFT(CourseID, 5)) = '{0}'", subjects[i])); } whereClause = string.Concat(whereClause, ")"); } AssertCourseCount(courses, whereClause); } }
public void GetCourses_Modality_Hybrid_Success() { using (OdsRepository repository = new OdsRepository()) { IList <ISectionFacet> facets = TestHelper.GetFacets(new ModalityFacet(ModalityFacet.Options.Hybrid)); IEnumerable <string> courses = repository.GetCourses(facets).Select(c => c.CourseID).Distinct(); int count = courses.Count(); // uncomment to get list for comparing foreach (string course in courses) { Console.WriteLine(course); } int expectedCount = _dataVerifier.GetCourseIDCountForSections(String.Format("isnull(SBCTCMisc1, '') like '8%'")); Assert.AreEqual(expectedCount, count); int allCount = _dataVerifier.GetCourseIDCountForSections("not ClassID is null"); Assert.IsTrue(allCount > count, "Online course count is not less than count of all courses."); } }
public void GetCourses_VerifyCcnFlag_True() { using (OdsRepository repository = new OdsRepository()) { IList<Course> courses = repository.GetCourses(); int expectedCount = _dataVerifier.GetCourseCount("CourseID like '%&%'"); Assert.AreEqual(expectedCount, courses.Where(c => c.IsCommonCourse).Count()); } }
public void GetCourses_VerifyCcnFlag_False() { using (OdsRepository repository = new OdsRepository()) { IList<Course> courses = repository.GetCourses(); Course course = courses.Where(s => !(s.Subject.EndsWith("&"))).Take(1).Single(); Assert.IsFalse(course.IsCommonCourse); } }
public void GetCourses_Modality_Telecourse_Success() { using (OdsRepository repository = new OdsRepository()) { IList<ISectionFacet> facets = TestHelper.GetFacets(new ModalityFacet(ModalityFacet.Options.Telecourse)); int count = repository.GetCourses(facets).Select(c => c.CourseID).Distinct().Count(); int expectedCount = _dataVerifier.GetCourseIDCountForSections(String.Format("SBCTCMisc1 like '1%'")); Assert.AreEqual(expectedCount, count); int allCount = _dataVerifier.GetCourseIDCountForSections("not ClassID is null"); Assert.IsTrue(allCount > count, "Online course count is not less than count of all courses."); } }
public void GetCourses_Modality_Online_Success() { using (OdsRepository repository = new OdsRepository()) { IList<ISectionFacet> facets = TestHelper.GetFacets(new ModalityFacet(ModalityFacet.Options.Online)); IList<Course> courses = repository.GetCourses(facets); Debug.Print("==> Online course count before DISTINCT: {0}", courses.Count); int count = courses.Select(c => c.CourseID).Distinct().Count(); Debug.Print("==> Online course count after DISTINCT: {0}", count); #if DEBUG foreach (string courseid in courses.Select(c => c.CourseID).Distinct()) { Debug.Print(courseid); } #endif int expectedCount = _dataVerifier.GetCourseIDCountForSections(String.Format("SBCTCMisc1 like '3%'")); Assert.AreEqual(expectedCount, count); int allCount = _dataVerifier.GetCourseIDCountForSections("not ClassID is null"); Assert.IsTrue(allCount > count, "Online course count is not less than count of all courses."); } }
public void GetCourses_Modality_Hybrid_Success() { using (OdsRepository repository = new OdsRepository()) { IList<ISectionFacet> facets = TestHelper.GetFacets(new ModalityFacet(ModalityFacet.Options.Hybrid)); IEnumerable<string> courses = repository.GetCourses(facets).Select(c => c.CourseID).Distinct(); int count = courses.Count(); // uncomment to get list for comparing foreach (string course in courses) { Console.WriteLine(course); } int expectedCount = _dataVerifier.GetCourseIDCountForSections(String.Format("isnull(SBCTCMisc1, '') like '8%'")); Assert.AreEqual(expectedCount, count); int allCount = _dataVerifier.GetCourseIDCountForSections("not ClassID is null"); Assert.IsTrue(allCount > count, "Online course count is not less than count of all courses."); } }
public void GetCourses_ByCourseID_Success() { using (OdsRepository repository = new OdsRepository()) { IEnumerable<ICourse> courses = repository.GetCourses(CourseID.FromString("art 101")); Assert.IsNotNull(courses); int allCoursesCount = courses.Count(); Assert.IsTrue(allCoursesCount > 0); int filteredCourseCount = courses.Where(c => Regex.IsMatch(c.CourseID.ToUpper(), @"ART\s+101")).Count(); Assert.AreEqual(allCoursesCount, filteredCourseCount); } }
public void GetCourses_WithDescription_Success() { using (OdsRepository repository = new OdsRepository()) { IList<Course> courses = repository.GetCourses(); int allCount = courses.Count; Assert.IsTrue(allCount > 0, "No courses found."); IEnumerable<Course> withNonNullDesc = courses.Where(c => c.Descriptions != null); Assert.IsTrue(withNonNullDesc.Count() > 0, "All Descriptions properties are null"); // TODO: resolve issues with some courses not having descriptions //IEnumerable<Course> withDescCounts = withNonNullDesc.Where(d => d.Descriptions.Count() > 0); ////IEnumerable<Course> withoutDescCounts = withNonNullDesc.Where(d => d.Descriptions.Count() <= 0); //Assert.AreEqual(allCount, withDescCounts.Count(), "{0} (out of {1}) Courses missing description entries", allCount - withDescCounts.Count(), allCount); } }
/// <summary> /// /// </summary> /// <param name="subjects"></param> private void AssertCourseCount(IList<string> subjects) { using (OdsRepository repository = new OdsRepository()) { IList<Course> courses = repository.GetCourses(subjects); Assert.IsTrue(courses.Count > 0, "No records were returned for '{0}'!", subjects); string whereClause = string.Empty; if (subjects.Count > 0) { whereClause = "("; for (int i = 0; i < subjects.Count; i++) { whereClause = string.Concat(whereClause, i > 0 ? " or " : string.Empty, String.Format("rtrim(LEFT(CourseID, 5)) = '{0}'", subjects[i])); } whereClause = string.Concat(whereClause, ")"); } AssertCourseCount(courses, whereClause); } }
/// <summary> /// /// </summary> /// <param name="subject"></param> /// <param name="number"></param> private void AssertCourseCount(string subject, string number) { using (OdsRepository repository = new OdsRepository()) { ICourseID courseID = CourseID.FromString(subject, number); IList<Course> courses = repository.GetCourses(courseID); Assert.IsTrue(courses.Count > 0, "No records were returned for '{0} {1}'!", subject, number); AssertCourseCount(courses, string.Format("rtrim(LEFT(CourseID, 5)) = '{0}' and LTRIM(RTRIM(SUBSTRING(CourseID, 6, 5))) = '{1}'", subject, number)); } }
/// <summary> /// /// </summary> /// <param name="subject"></param> private void AssertCourseCount(string subject) { using (OdsRepository repository = new OdsRepository()) { IList<Course> courses = repository.GetCourses(subject); Assert.IsTrue(courses.Count > 0, "No records were returned for '{0}'!", subject); AssertCourseCount(courses, string.Format("rtrim(LEFT(CourseID, 5)) = '{0}'", subject)); } }
public void CourseFootnotes_Success() { using (OdsRepository repository = new OdsRepository()) { IList<Course> courses = repository.GetCourses(); // IList<Course> courses = repository.GetCourses("engl"); Assert.IsTrue(courses.Count > 0, "No courses returned"); #if DEBUG Debug.Print("==== All courses returned ({0}) ====", courses.Count); foreach (Course course in courses) { Debug.Print("{0}", course.CourseID); } #endif IEnumerable<Course> withFootnotes = courses.Where(c => c.Footnotes.Count > 0); #if DEBUG Debug.Print("==== Courses with footnotes ({0}) ====", withFootnotes.Count()); foreach (Course course in withFootnotes) { Debug.Print("{0}\t({1})", course.CourseID, course.Footnotes.Count); } #endif int actual = withFootnotes.Count(); int expected = _dataVerifier.GetCourseCount("((FootnoteID1 IN (SELECT f.footnoteid FROM dbo.vw_Footnote f) or FootnoteID2 IN (SELECT f.FootnoteID FROM dbo.vw_Footnote f)))"); // int expected = _dataVerifier.GetCourseCount("(isnull(FootnoteID1, '') <> '' or ISNULL(FootnoteID2, '') <> '') and rtrim(left(replace(CourseID, '&', ' '), 5)) = 'engl'"); Assert.AreEqual(expected, actual); } }
public ActionResult ClassDetails(string Prefix, string ClassNum, string format) { ICourseID courseID = CourseID.FromString(Prefix, ClassNum); ClassDetailsModel model; using (OdsRepository repository = new OdsRepository(HttpContext)) { IList<Course> courses; using (_profiler.Step("ODSAPI::GetCourses()")) { courses = repository.GetCourses(courseID); } IList<YearQuarter> navigationQuarters = Helpers.GetYearQuarterListForMenus(repository); IList<YearQuarter> quartersOffered = new List<YearQuarter>(); string learningOutcomes = string.Empty; if (courses.Count > 0) { using (_profiler.Step("Getting Course counts (per YRQ)")) { // Identify which, if any, of the current range of quarters has Sections for this Course foreach (YearQuarter quarter in navigationQuarters) { // TODO: for better performance, overload method to accept more than one YRQ if (repository.SectionCountForCourse(courseID, quarter) > 0) { quartersOffered.Add(quarter); } } } // Get the course learning outcomes using (_profiler.Step("Retrieving course outcomes")) { learningOutcomes = Helpers.GetCourseOutcome(courseID); } } // Create the model model = new ClassDetailsModel { Courses = courses, CurrentQuarter = repository.CurrentYearQuarter, NavigationQuarters = navigationQuarters, QuartersOffered = quartersOffered, CMSFootnote = GetCmsFootnote(courseID), LearningOutcomes = learningOutcomes, }; Subject subject = SubjectInfo.GetSubjectFromPrefix(Prefix); if (subject != null) { SubjectInfoResult programInfo = SubjectInfo.GetSubjectInfo(subject.Slug); model.Slug = programInfo.Subject.Slug; model.SubjectTitle = programInfo.Subject.Title; model.SubjectIntro = programInfo.Subject.Intro; model.DepartmentTitle = programInfo.Department.Title; model.DepartmentURL = programInfo.Department.URL; model.DivisionTitle = programInfo.Division.Title; model.DivisionURL = programInfo.Division.URL; } } if (format == "json") { // NOTE: AllowGet exposes the potential for JSON Hijacking (see http://haacked.com/archive/2009/06/25/json-hijacking.aspx) // but is not an issue here because we are receiving and returning public (e.g. non-sensitive) data return Json(model, JsonRequestBehavior.AllowGet); } return View(model); }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="repository"></param> private void VerifyModalityTimes(string start, string end, OdsRepository repository) { TimeSpan startTime = TimeSpan.Parse(start); TimeSpan endTime = TimeSpan.Parse(end); IList<ISectionFacet> facets = TestHelper.GetFacets(new TimeFacet(startTime, endTime)); int count = repository.GetCourses(facets).Select(c => c.CourseID).Distinct().Count(); Assert.IsTrue(count > 0, "No sections were returned"); int allCount = _dataVerifier.GetCourseIDCountForSections("not ClassID is null"); Assert.IsTrue(allCount > count, "Filtered course count ({0}) is not less than count of all courses ({1}).", count, allCount); }
public void GetCourses_VerifyIsVariableCredit() { using (OdsRepository repository = new OdsRepository()) { IList<string> subjects = new List<string> {"ENGL", "ENGL&"}; IList<Course> courses = repository.GetCourses(subjects); Assert.IsTrue(courses.Count > 0); int count = _dataVerifier.GetCourseCount("(rtrim(left(CourseID, 5)) = 'ENGL' or rtrim(left(CourseID, 5)) = 'ENGL&') AND isnull(VariableCredits, 0) = 1"); Assert.AreEqual(count, courses.Where(c => c.IsVariableCredits).Count()); } }
public ActionResult Subject(string Subject, string format) { using (OdsRepository repository = new OdsRepository(HttpContext)) { SubjectInfoResult subject = SubjectInfo.GetSubjectInfo(Subject); IList<string> prefixes = subject.CoursePrefixes.Select(p => p.CoursePrefixID).ToList(); IEnumerable<Course> coursesEnum = (prefixes.Count > 0 ? repository.GetCourses(prefixes) : repository.GetCourses()) .Distinct() .OrderBy(c => c.Subject) .ThenBy(c => c.Number); // TODO: Utilize SubjectModel in SubjectViewModel SubjectViewModel model = new SubjectViewModel { Courses = coursesEnum, Slug = subject.Subject.Slug, SubjectTitle = subject.Subject.Title, SubjectIntro = subject.Subject.Intro, DepartmentTitle = subject.Department.Title, DepartmentURL = subject.Department.URL, CurrentQuarter = repository.CurrentYearQuarter, NavigationQuarters = Helpers.GetYearQuarterListForMenus(repository) }; if (format == "json") { // NOTE: AllowGet exposes the potential for JSON Hijacking (see http://haacked.com/archive/2009/06/25/json-hijacking.aspx) // but is not an issue here because we are receiving and returning public (e.g. non-sensitive) data return Json(model, JsonRequestBehavior.AllowGet); } ViewBag.LinkParams = Helpers.getLinkParams(Request); SetCommonViewBagVars(repository, string.Empty, string.Empty); return View(model); } }
public void GetCourses_VerifySortedByCourseID() { using (OdsRepository repository = new OdsRepository()) { IList<Course> courses = repository.GetCourses("CHEM"); string prevCourseID = " "; // TODO: is there a more efficient way to determine that the whole list is sorted? foreach (Course course in courses) { string thisCourseID = course.CourseID; Assert.IsTrue(thisCourseID.CompareTo(prevCourseID) >= 0, "Invalid order found: [{0}] is not less than [{1}]", prevCourseID, thisCourseID); prevCourseID = thisCourseID; } } }
public ActionResult ClassEdit(string CourseNumber, string Subject, bool IsCommonCourse) { if (HttpContext.User.Identity.IsAuthenticated) { string fullCourseId = Helpers.BuildCourseID(CourseNumber, Subject, IsCommonCourse); ICourseID courseID = CourseID.FromString(fullCourseId); CourseMeta itemToUpdate = null; var hpFootnotes = string.Empty; string courseTitle = string.Empty; using (ClassScheduleDb db = new ClassScheduleDb()) { if(db.CourseMetas.Any(s => s.CourseID.Trim().ToUpper() == fullCourseId.ToUpper())) { //itemToUpdate = db.CourseFootnotes.Single(s => s.CourseID.Substring(0, 5).Trim().ToUpper() == subject.Trim().ToUpper() && // s.CourseID.Trim().EndsWith(courseID.Number) itemToUpdate = db.CourseMetas.Single(s => s.CourseID.Trim().ToUpper() == fullCourseId.ToUpper()); } using (OdsRepository repository = new OdsRepository()) { try { IList<Course> coursesEnum = repository.GetCourses(courseID); foreach (Course course in coursesEnum) { hpFootnotes = course.Footnotes.ToArray().Mash(" "); // BUG: If more than one course is returned from the API, this will ignore all Titles except for the last one courseTitle = course.Title; } } catch(InvalidOperationException ex) { _log.Warn(m => m("Ignoring Exception while attempting to retrieve footnote and title data for CourseID '{0}'\n{1}", courseID, ex)); } } ClassFootnote localClass = new ClassFootnote(); localClass.CourseID = MvcApplication.SafePropertyToString(itemToUpdate, "CourseID", fullCourseId); localClass.Footnote = MvcApplication.SafePropertyToString(itemToUpdate, "Footnote", string.Empty); localClass.HPFootnote = hpFootnotes; localClass.LastUpdated = MvcApplication.SafePropertyToString(itemToUpdate, "LastUpdated", string.Empty); localClass.LastUpdatedBy = MvcApplication.SafePropertyToString(itemToUpdate, "LastUpdatedBy", string.Empty); localClass.CourseTitle = courseTitle; return PartialView(localClass); } } return PartialView(); }
public void Research() { using (OdsRepository repository = new OdsRepository()) { string courseId = "CEO 196"; IList<Course> courses = repository.GetCourses(CourseID.FromString(courseId)); Assert.IsTrue(courses.Count > 0); var foo = courses.Select(c => c.CourseID); Assert.AreEqual(courses.Count, courses.Count(c => c.CourseID == courseId)); } }