public void GetCoursesBySemester_ReturnsListOfOneCourseAndOneMainTeacher() { // Arrange: // Act: var courses = _service.GetCourseInstancesBySemester(1, null, "20153"); // Assert: Assert.Equal(1, courses.Items.Count); Assert.Equal(NAME_DABS, courses.Items[0].MainTeacher); }
public void GetCoursesBySemester_ReturnsAllCoursesOfSemester() { // Arrange: string semester0 = "20163", semester1 = "20013"; // Act: var result0 = _service.GetCourseInstancesBySemester(semester0); var result1 = _service.GetCourseInstancesBySemester(semester1); // Assert: Assert.Equal(3, result0.Count); var veft = result0.SingleOrDefault(x => x.TemplateID == VEFT_TEMPLATE_ID); var prog = result0.SingleOrDefault(x => x.TemplateID == PROG_TEMPLATE_ID); var gagn = result0.SingleOrDefault(x => x.TemplateID == GAGN_TEMPLATE_ID); Assert.Equal(COURSEID_VEFT_20163, veft.CourseInstanceID); Assert.Equal(VEFT_TEMPLATE_NAME, veft.Name); Assert.Equal(VEFT_TEMPLATE_ID, veft.TemplateID); Assert.Equal(COURSEID_PROG_20163, prog.CourseInstanceID); Assert.Equal(PROG_TEMPLATE_NAME, prog.Name); Assert.Equal(PROG_TEMPLATE_ID, prog.TemplateID); Assert.Equal(COURSEID_GAGN_20163, gagn.CourseInstanceID); Assert.Equal(GAGN_TEMPLATE_NAME, gagn.Name); Assert.Equal(GAGN_TEMPLATE_ID, gagn.TemplateID); Assert.Equal(0, result1.Count); }
public void GetCoursesBySemester_ReturnsEmptyListWhenNoDataDefined() { // Arrange: var emptyList = new List <CourseInstance> { }; _mockUnitOfWork.SetRepositoryData(emptyList); // Act: var obj = _service.GetCourseInstancesBySemester(); // Assert: Assert.Equal(obj.Count, 0); }
public void GetCoursesBySemester_ReturnsAllCoursesOnASelectedSemester() { // Arrange: var semester = "20163"; // Act: var result = _service.GetCourseInstancesBySemester(semester); // Assert: var expectedCount = 1; Assert.AreEqual(expectedCount, result.Count); Assert.AreEqual(COURSEID_VEFT_20163, result[0].CourseInstanceID); Assert.AreEqual(TEMPLATE_VEFT, result[0].TemplateID); }
public IActionResult GetCoursesBySemester([FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10, string semester = null) { var languageHeader = Request.Headers["Accept-Language"]; // TODO: figure out the requested language (if any!) // and pass it to the service provider! return(Ok(_service.GetCourseInstancesBySemester(pageNumber, pageSize, semester, languageHeader))); }
public void GetCoursesBySemester_ReturnsEmptyListWhenNoDataDefined() { // Arrange: var semesterWithNoCourse = "20173"; // Act: var result = _service.GetCourseInstancesBySemester(semesterWithNoCourse); // Assert: Assert.IsTrue(result.Count == 0); }
public void GetCoursesBySemester_ReturnsAllCoursesOfSemester() { // Arrange: string semester1 = "20163", semester2 = "20013"; // Act: var result0 = _service.GetCourseInstancesBySemester(semester1); var result1 = _service.GetCourseInstancesBySemester(semester2); // Assert: Assert.AreEqual(1, result0.Count); Assert.AreEqual(COURSEID_VEFT_20163, result0[0].CourseInstanceID); Assert.AreEqual(VEFT_TEMPLATE_NAME, result0[0].Name); Assert.AreEqual(VEFT_TEMPLATEID, result0[0].TemplateID); Assert.AreEqual(0, result1.Count); }
public IActionResult GetCoursesBySemester(int page = 1, string semester = null) { try { return(Ok(_service.GetCourseInstancesBySemester( LanguageUtils.GetLanguage(Request.Headers["Accept-Language"]), page, semester))); } catch (AppObjectNotFoundException e) { return(StatusCode(415, e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public void GetCoursesBySemester_ReturnsEmptyListWhenNoDataDefined() { // Arrange: var mockUnitOfWork = new MockUnitOfWork <MockDataContext>(); var service = new CoursesServiceProvider(mockUnitOfWork); // Act: var result = service.GetCourseInstancesBySemester("20151"); // Assert: var expected = new List <CourseInstanceDTO>(); Assert.AreEqual(expected.Count, result.Count); }
public void GetCoursesBySemester_ReturnsEmptyListWhenNoDataDefined() { // Arrange: // Act: List <CourseInstanceDTO> dto = _service.GetCourseInstancesBySemester("20173"); // Assert: Assert.IsNotNull(dto); Assert.AreEqual(0, dto.Count); }
public IActionResult GetCoursesBySemester(string semester = null, int page = 1) { string language = Request.Headers["Accept-Language"]; try { return(Ok(_service.GetCourseInstancesBySemester(semester, page, language))); } catch (AppObjectNotFoundException) { return(NotFound("The page number entered does not match any results.")); } }
public void GetCoursesBySemester_ReturnsEmptyListWhenNoDataDefined() { // Arrange: // Act: var dto = _service.GetCourseInstancesBySemester("20123"); // Assert: Assert.AreEqual(dto.SingleOrDefault(), null); }
public IHttpActionResult GetCoursesBySemester(string semester = null, int page = 1) { string language = Request.Headers.AcceptLanguage.ToString(); //According to the lecture.. if Accept-Language is English, then English, otherwise Icelandic. if (language.Length > 1 && language.Substring(0, 2) == "en") { language = Request.Headers.AcceptLanguage.ToString().Substring(0, 2); } else { language = "is"; } return(Ok(_service.GetCourseInstancesBySemester(semester, page, language))); }
public IActionResult GetCoursesBySemester([FromQuery] string semester = null, [FromQuery] int pageNumber = 1) { // TODO: figure out the requested language (if any!) // and pass it to the service provider! string languageHeader = Request.Headers["Accept-Language"]; var retVal = _service.GetCourseInstancesBySemester(semester, languageHeader, pageNumber); if (pageNumber > retVal.TotalPages || pageNumber < 0) { return(NotFound("Not found")); // 404 } if (retVal == null) { return(StatusCode(500)); } return(Ok(retVal)); }
public IActionResult GetCoursesBySemester(int?page, string semester = null) { var thePage = 1; if (page.HasValue) { thePage = page.Value; } var lang = Request.Headers["Accept-Language"].ToString(); var langs = lang.Split(','); try { var pageResult = _service.GetCourseInstancesBySemester(thePage, langs[0], semester); return(Ok(pageResult)); } catch (AppObjectNotFoundException) { return(NotFound()); } }
[CacheOutput(ClientTimeSpan = 86400, ServerTimeSpan = 86400)] //Cache for 86400 s. Put the e-tag in If-None-Match public IHttpActionResult GetCoursesBySemester(string semester = null, int page = 1) { // TODO: figure out the requested language (if any!) // and pass it to the service provider! return(Ok(_service.GetCourseInstancesBySemester(semester, page))); }