/// <summary> /// Adds the catalog. /// </summary> /// <param name="catalog">The catalog.</param> public void AddCatalog(Catalog catalog) { using (var context = new MyApplicationContext()) { context.Catalogs.Add(catalog); context.SaveChanges(); } }
public void TestCatalogUpdate() { Catalog catalog = new Catalog() { Id = 14 }; catalogDataService.Expect(dao => dao.UpdateCatalog(catalog)); catalogService.UpdateCatalog(catalog); catalogDataService.VerifyAllExpectations(); }
public void TestCatalogAdd() { Catalog catalog = new Catalog() { Id = 15 }; catalogDataService.Expect(dao => dao.AddCatalog(catalog)); catalogService.AddCatalog(catalog); catalogDataService.VerifyAllExpectations(); }
/// <summary> /// Deletes the catalog. /// </summary> /// <param name="catalog">The catalog.</param> public void DeleteCatalog(Catalog catalog) { using (var context = new MyApplicationContext()) { var newProd = new Catalog { Id = catalog.Id }; context.Catalogs.Attach(newProd); context.Catalogs.Remove(newProd); context.SaveChanges(); } }
public void SetUp() { // a valid catalog catalog = new Catalog() { Student = new Student(), Mark = 5, Exam = new Exam() }; }
public void TestCatalogGetById() { int id = 15; Catalog catalog = new Catalog() { Id = id }; catalogDataService.Stub(dao => dao.GetCatalogById(id)).Return(catalog); Catalog result = catalogService.GetCatalogById(id); Assert.AreEqual(id, result.Id); }
/// <summary> /// Updates the catalog. /// </summary> /// <param name="catalog">The catalog.</param> /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception> public void UpdateCatalog(Catalog catalog) { using (var context = new MyApplicationContext()) { Catalog catalogRef = context.Catalogs.Where(c => c.Id == catalog.Id).SingleOrDefault(); if (catalogRef != null) { catalogRef = catalog; context.SaveChanges(); } else throw new KeyNotFoundException(); } }
public void TestStudentHasToChangeExamOne() { Catalog catalog1 = new Catalog() { Id = 140, Mark = 4 }; Catalog catalog2 = new Catalog() { Id = 260, Mark = 4 }; Catalog catalog3 = new Catalog() { Id = 260, Mark = 4 }; Course course = new Course() { Id = 12 }; Student student = new Student() { Semesters = { new Semester() { Courses = { course } } } }; IList<Catalog> catalogs = new List<Catalog>() { catalog1, catalog2, catalog3 }; catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course)).Return(catalogs); Assert.AreEqual(1, catalogService.GetCoursesWhichStudentNeedsToChange(student).Count); }
public void TestStudentCantAttendExamAlreadyTookItBoundry() { Catalog catalog1 = new Catalog() { Id = 140, Mark = 4 }; Catalog catalog2 = new Catalog() { Id = 260, Mark = 4 }; Catalog catalog3 = new Catalog() { Id = 260, Mark = 10 }; Student student = new Student(); Course course = new Course() { Id = 12 }; IList<Catalog> catalogs = new List<Catalog>() { catalog1, catalog2, catalog3 }; catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course)).Return(catalogs); Assert.IsFalse(catalogService.CanStudentAttendExamAtCourse(student, course)); }
public void TestStudentCanAttendExamLastTime() { Catalog catalog1 = new Catalog() { Id = 140, Mark = 4 }; Catalog catalog2 = new Catalog() { Id = 260, Mark = 4 }; Student student = new Student(); Course course = new Course() { Id = 12 }; IList<Catalog> catalogs = new List<Catalog>() { catalog1, catalog2 }; catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course)).Return(catalogs); Assert.IsTrue(catalogService.CanStudentAttendExamAtCourse(student, course)); }
public void DeleteCatalog(Catalog catalog) { catalogDataService.DeleteCatalog(catalog); }
public void TestStudentNotPassedCourse() { Catalog catalog1 = new Catalog() { Id = 14, Mark = 4 }; Catalog catalog2 = new Catalog() { Id = 26, Mark = 4 }; Student student = new Student() { Id = 12 }; Course course = new Course() { Id = 12 }; IList<Catalog> catalogs = new List<Catalog>() { catalog1, catalog2 }; catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course)).Return(catalogs); Assert.IsFalse(catalogService.StudentPassedCourse(student, course)); }
public void TestStudentPassedCourse() { Catalog catalog1 = new Catalog() { Id = 14, Mark = 7 }; Student student = new Student() { Id = 12 }; Course course = new Course() { Id = 12 }; IList<Catalog> catalogs = new List<Catalog>() { catalog1 }; catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course)).Return(catalogs); var result = catalogService.StudentPassedCourse(student, course); Assert.IsTrue(result); }
public void UpdateCatalog(Catalog catalog) { catalogDataService.UpdateCatalog(catalog); }
public void TestStudentHasToChangePackageBecausoOTwoExams() { Catalog catalog1 = new Catalog() { Id = 140, Mark = 4 }; Catalog catalog2 = new Catalog() { Id = 260, Mark = 4 }; Catalog catalog3 = new Catalog() { Id = 260, Mark = 4 }; Catalog catalog4 = new Catalog() { Id = 260, Mark = 4 }; Course course1 = new Course() { Id = 12 }; Course course2 = new Course() { Id = 13 }; course1.Corequisites.Add(course2); course2.Corequisites.Add(course1); Student student = new Student() { Semesters = { new Semester() { Courses = { course1, course2 } } } }; IList<Catalog> catalogs1 = new List<Catalog>() { catalog1, catalog2, catalog3 }; IList<Catalog> catalogs2 = new List<Catalog>() { catalog1, catalog2, catalog4 }; catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course1)).Return(catalogs1); catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course2)).Return(catalogs2); Assert.AreEqual(2, catalogService.GetCoursesWhichStudentNeedsToChange(student).Count); }
public void TestStudentNotPassedCoursePacketBecauseSelf() { Catalog catalog1 = new Catalog() { Id = 14, Mark = 4 }; Catalog catalog2 = new Catalog() { Id = 26, Mark = 10 }; Student student = new Student(); Course course1 = new Course() { Id = 12 }; Course course2 = new Course() { Id = 13 }; course1.Corequisites.Add(course2); course2.Corequisites.Add(course1); IList<Catalog> catalogs1 = new List<Catalog>() { catalog1 }; IList<Catalog> catalogs2 = new List<Catalog>() { catalog2 }; catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course1)).Return(catalogs1); catalogDataService.Stub(dao => dao.GetAllStudentCatalogsForCourse(student, course2)).Return(catalogs2); Assert.IsFalse(catalogService.StudentPassedCoursePacket(student, course1)); }
public void TestCatalogGetListOfCatalogs() { Catalog catalog1 = new Catalog() { Id = 11 }; Catalog catalog2 = new Catalog() { Id = 12 }; IList<Catalog> catalogs = new List<Catalog>() { catalog1, catalog2 }; catalogDataService.Stub(dao => dao.GetAllCatalogs()).Return(catalogs); var result = catalogService.GetListOfCatalogs(); Assert.AreEqual(result.Count, catalogs.Count); }
public void AddCatalog(Catalog catalog) { catalogDataService.AddCatalog(catalog); }