コード例 #1
0
 /// <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();
     }
 }
コード例 #2
0
        public void TestCatalogUpdate()
        {
            Catalog catalog = new Catalog() { Id = 14 };

            catalogDataService.Expect(dao => dao.UpdateCatalog(catalog));

            catalogService.UpdateCatalog(catalog);

            catalogDataService.VerifyAllExpectations();
        }
コード例 #3
0
        public void TestCatalogAdd()
        {
            Catalog catalog = new Catalog() { Id = 15 };

            catalogDataService.Expect(dao => dao.AddCatalog(catalog));

            catalogService.AddCatalog(catalog);

            catalogDataService.VerifyAllExpectations();
        }
コード例 #4
0
 /// <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();
     }
 }
コード例 #5
0
 public void SetUp()
 {
     // a valid catalog
     catalog = new Catalog()
     {
         Student = new Student(),
         Mark = 5,
         Exam = new Exam()
     };
 }
コード例 #6
0
        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);
        }
コード例 #7
0
 /// <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();
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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));
        }
コード例 #11
0
 public void DeleteCatalog(Catalog catalog)
 {
     catalogDataService.DeleteCatalog(catalog);
 }
コード例 #12
0
        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));
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public void UpdateCatalog(Catalog catalog)
 {
     catalogDataService.UpdateCatalog(catalog);
 }
コード例 #15
0
        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);
        }
コード例 #16
0
        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));
        }
コード例 #17
0
        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);
        }
コード例 #18
0
 public void AddCatalog(Catalog catalog)
 {
     catalogDataService.AddCatalog(catalog);
 }