コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryString"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public IList <ICourseID> GetCourseIDListFromQuery(string queryString, int count, string whereClause = null)
        {
            IList <ICourseID> ids = new List <ICourseID>(count);

            string sql = string.Format("select top {0} CourseID from (select distinct CourseID from vw_Class where CourseTitle like '%{1}%' {4} {2} {3}) a", count, queryString, _yrqFilter, _sectionFilter, whereClause ?? string.Empty);

            try
            {
                if (_conn.State != ConnectionState.Open)
                {
                    _conn.Open();
                }

                using (DbCommand cmd = _conn.CreateCommand())
                {
                    cmd.CommandText = sql;

                    cmd.ExecuteScalar().ToString();
                    using (DbDataReader rs = cmd.ExecuteReader())
                    {
                        while (rs.Read())
                        {
                            ids.Add(CourseID.FromString(rs["CourseID"].ToString().Trim()));
                        }
                    }

                    return(ids);
                }
            }
            catch (SqlException ex)
            {
                throw new DataException(String.Format("An error occurred while attempting execute the following SQL: \"{0}\"", sql), ex);
            }
        }
コード例 #2
0
        public void GetSectionsByCourseID_Success()
        {
            using (OdsRepository repository = new OdsRepository())
            {
                IList <Section> sections = repository.GetSections(CourseID.FromString("ART 101"), facetOptions: TestHelper.GetFacets());

                Assert.IsTrue(sections.Count > 0);
            }
        }
コード例 #3
0
        public void ToStringConversion_SpacesInSubject()
        {
            ICourseID target   = CourseID.FromString("C S C", "112");
            string    expected = "C S C 112";
            string    actual   = target.ToString();

            Assert.AreEqual(expected, actual);
            Assert.IsFalse(target.IsCommonCourse);
        }
コード例 #4
0
        public void ToStringConversion_CommonCourse_SpacesInSubject()
        {
            ICourseID target   = CourseID.FromString("C J&", "101");
            string    expected = "C J 101";
            string    actual   = target.ToString();

            Assert.AreEqual(expected, actual);
            Assert.IsTrue(target.IsCommonCourse);
        }
コード例 #5
0
        public void ToStringConversion()
        {
            ICourseID target   = CourseID.FromString("ART", "101");
            string    expected = "ART 101";
            string    actual   = target.ToString();

            Assert.AreEqual(expected, actual);
            Assert.IsFalse(target.IsCommonCourse);
        }
コード例 #6
0
        public void FromString_SubjectAndNumber_CommonCourse()
        {
            string    subject = "ART";
            string    number  = "101";
            ICourseID actual  = CourseID.FromString(string.Concat(subject, "&"), number);

            Assert.AreEqual(subject, actual.Subject);
            Assert.AreEqual(number, actual.Number);
            Assert.IsTrue(actual.IsCommonCourse, "Common Course flag is not set");
        }
コード例 #7
0
        public void GetSectionsByCourseID_WithYrq_Success()
        {
            using (OdsRepository repository = new OdsRepository())
            {
                YearQuarter     yrq      = YearQuarter.FromString("B012");
                IList <Section> sections = repository.GetSections(CourseID.FromString("ART 101"), yrq);

                Assert.IsTrue(sections.Count > 0);
            }
        }
コード例 #8
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));
            }
        }
コード例 #9
0
        public void FromString_SubjectAndNumber_CommonCourse_2charSubject()
        {
            // this test comes from a real-world scenario which revealed a bug. 5/07/2012, [email protected]
            string subject = TestHelper.Data.ShortCourseSubject;
            string number  = TestHelper.Data.ShortCourseSubjectNumber;

            ICourseID actual = CourseID.FromString(string.Concat(subject, TestHelper.Data.CommonCourseCharacter), number);

            Assert.AreEqual(subject, actual.Subject);
            Assert.AreEqual(number, actual.Number);
            Assert.IsTrue(actual.IsCommonCourse, "Common Course flag is not set");
        }
コード例 #10
0
        [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));
            }
        }
コード例 #11
0
        public void FromString_SubjectAndNumber_WithSpaces_CommonCourse()
        {
            string subject = "P E";
            string number  = "100";

            ICourseID actual = CourseID.FromString(string.Concat(subject, "&"), number);

            Assert.AreEqual(subject, actual.Subject);
            Assert.AreEqual(number, actual.Number);
            Assert.AreEqual(string.Concat(subject, " ", number), actual.ToString());

            Assert.IsTrue(actual.IsCommonCourse);
        }
コード例 #12
0
        public void FromString_SubjectAndNumber()
        {
            string subject = "CEO";
            string number  = "196";

            ICourseID actual = CourseID.FromString(subject, number);

            Assert.AreEqual(subject, actual.Subject);
            Assert.AreEqual(number, actual.Number);
            Assert.AreEqual(string.Concat(subject, " ", number), actual.ToString());

            Assert.IsFalse(actual.IsCommonCourse);
        }
コード例 #13
0
        public void FromString_SingleParameter_TabSeparator()
        {
            string subject      = "ART";
            string number       = "101";
            string realCourseID = string.Concat(subject, "\t", number);

            ICourseID actual = CourseID.FromString(realCourseID);

            Assert.AreEqual(subject, actual.Subject);
            Assert.AreEqual(number, actual.Number);
            Assert.AreEqual(string.Concat(subject, " ", number), actual.ToString());

            Assert.IsFalse(actual.IsCommonCourse);
        }
コード例 #14
0
        public void FromString_SingleParameter()
        {
            string subject  = "ART";
            string number   = "101";
            string courseId = string.Concat(subject, " ", number);

            ICourseID actual = CourseID.FromString(courseId);

            Assert.AreEqual(subject, actual.Subject);
            Assert.AreEqual(number, actual.Number);
            Assert.AreEqual(courseId, actual.ToString());

            Assert.IsFalse(actual.IsCommonCourse);
        }
コード例 #15
0
        public void ForCourseIDCommonCourse_CurrentRegistrationQuarter()
        {
            using (OdsRepository repository = new OdsRepository())
            {
                ICourseID   courseID = CourseID.FromString("ENGL& 101");
                YearQuarter yrq      = repository.CurrentRegistrationQuarter;

                int sectionCount = repository.SectionCountForCourse(courseID, yrq, TestHelper.GetFacets(false));
                Assert.IsTrue(sectionCount > 0, string.Format("No sections found for '{0}' in '{1}'", courseID, yrq.FriendlyName));

                int expectedCount = _dataVerifier.GetSectionCount(string.Format("YearQuarterID = '{0}' AND CourseID LIKE '{1}%{2}' AND CourseID LIKE '%&%'", yrq, courseID.Subject, courseID.Number));
                Assert.AreEqual(expectedCount, sectionCount);
            }
        }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
//		[Conditional("BC_ONLY")]
        public void GetSectionsByCourseID_WithYrq_VerifyInstructorEmail()
        {
            using (OdsRepository repository = new OdsRepository())
            {
                YearQuarter yrq      = YearQuarter.FromString("B233");
                string      courseId = "ART 101";

                IList <Section> sections = repository.GetSections(CourseID.FromString(courseId), yrq, TestHelper.GetFacets());
                Assert.IsTrue(sections.Count > 0, "No sections found for {0} in {1}", courseId, yrq.FriendlyName);

                int emailCount = sections.Where(s => s.Offered.Where(o => !string.IsNullOrWhiteSpace(o.InstructorEmail)).Count() > 0).Count();
                Assert.IsTrue(emailCount > 0, "No instructor e-mails found.");
            }
        }
コード例 #18
0
        public void FromString_SingleParameter_WithSpaces_CommonCourse_TabSeparated()
        {
            string subject      = "C J";
            string number       = "100";
            string courseId     = string.Concat(subject, " ", number);
            string realCourseID = string.Concat(subject, "&\t", number);

            ICourseID actual = CourseID.FromString(realCourseID);

            Assert.AreEqual(subject, actual.Subject);
            Assert.AreEqual(number, actual.Number);
            Assert.AreEqual(courseId, actual.ToString());

            Assert.IsTrue(actual.IsCommonCourse);
        }
コード例 #19
0
        public void FromString_SingleParameter_CommonCourse_NoSeparatingSpace()
        {
            string subject      = "ACCT";
            string number       = "101";
            string courseId     = string.Concat(subject, " ", number);
            string realCourseID = string.Concat(subject, "&", number);

            ICourseID actual = CourseID.FromString(realCourseID);

            Assert.AreEqual(subject, actual.Subject);
            Assert.AreEqual(number, actual.Number);
            Assert.AreEqual(courseId, actual.ToString());

            Assert.IsTrue(actual.IsCommonCourse);
        }
コード例 #20
0
        public void RetrievingPresentAndFutureDescriptions()
        {
            using (OdsRepository ods = new OdsRepository())
            {
                ICourseID courseID = CourseID.FromString("ECON&201");
                IList <CourseDescription> descs = ods.GetCourseDescription(courseID, YearQuarter.FromString("B234"));

                Assert.IsNotNull(descs);

                foreach (CourseDescription desc in descs)
                {
                    Console.Out.WriteLine("[{0}] {1}", desc.YearQuarterBegin, desc.Description);
                }

                Assert.IsTrue(descs.Count > 1, "ECON& 201 should have 2 descriptions, but only has {0}", descs.Count);
            }
        }
コード例 #21
0
        public void GetSections_VerifyInstructor()
        {
            using (OdsRepository repository = new OdsRepository())
            {
                IList <Section> sections = repository.GetSections(CourseID.FromString("ENGL", "101"));

                ISection sec = sections.Where(s => s.Offered != null && s.Offered.Where(o => !string.IsNullOrWhiteSpace(o.InstructorID) &&
                                                                                        !string.IsNullOrWhiteSpace(o.InstructorName)
                                                                                        )
                                              .Count() > 0)
                               .Take(1).Single();

                OfferedItem item = sec.Offered.Where(o => !string.IsNullOrWhiteSpace(o.InstructorID) &&
                                                     !string.IsNullOrWhiteSpace(o.InstructorName)
                                                     )
                                   .Take(1).Single();

                string expected = _dataVerifier.GetInstructorName(item.InstructorID);

                Assert.AreEqual(expected, item.InstructorName);
            }
        }
コード例 #22
0
        public void CourseDescription_CourseIDLookup_Success()
        {
            using (OdsRepository repository = new OdsRepository())
            {
                IEnumerable <CourseDescription> courseDescriptions = repository.GetCourseDescription(CourseID.FromString("art 101"));
                Assert.IsNotNull(courseDescriptions, "Method returned null");

                int allCoursesCount = courseDescriptions.Count();
                Assert.IsTrue(allCoursesCount > 0, "{0} descriptions were returned", allCoursesCount);

                int filteredCourseCount = courseDescriptions.Where(c => Regex.IsMatch(c.CourseID.ToUpper(), @"ART\s+101")).Count();
                Assert.AreEqual(allCoursesCount, filteredCourseCount);
            }
        }