public void Get_presences_by_student_and_subject_test() { var repo = new PresenceRepository(this.context); var studrepo = new StudentRepository(this.context); var timerepo = new TimeTableRepository(this.context); var classrepo = new ClassRepository(this.context); var subrepo = new SubjectRepository(this.context); ClassEntity clazz = new ClassEntity("GR1"); classrepo.AddNew(clazz); StudentEntity model = new StudentEntity("Aneta", "Dams", clazz, true); studrepo.AddNew(model); SubjectEntity subject = new SubjectEntity("AM", "Analiza Matematyczna"); subrepo.AddNew(subject); TimeTableEntity timeTable = new TimeTableEntity("poniedziałek", clazz, subject); var model1 = new PresenceEntity(model, subject, DateTime.Now.Date, true); var model2 = new PresenceEntity(model, subject, DateTime.Now.Date.AddDays(2), true); repo.AddNew(model1); repo.AddNew(model2); var result= repo.GetAllByStudentAndSubject(model.Id, subject.Id); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual(model1.Id, result[0].Id); Assert.AreEqual(model2.Id, result[1].Id); }
public PresenceEntity(StudentEntity student, SubjectEntity subject, DateTime date, bool present) { this.Student = student; this.Subject = subject; this.Date = date; this.Present = present; }
public void Add_new_student_test() { var repo = new StudentRepository(this.context); var classRepo = new ClassRepository(context); var clazz = new ClassEntity("GR1"); classRepo.AddNew(clazz); var model = new StudentEntity("Aneta","Dams", clazz, true); repo.AddNew(model); }
public void Add_new_presence_test() { var repo = new PresenceRepository(this.context); var studrepo = new StudentRepository(this.context); var timerepo = new TimeTableRepository(this.context); var classrepo = new ClassRepository(this.context); var subrepo = new SubjectRepository(this.context); ClassEntity clazz = new ClassEntity("GR1"); classrepo.AddNew(clazz); StudentEntity model = new StudentEntity("Aneta", "Dams", clazz,true); studrepo.AddNew(model); SubjectEntity subject = new SubjectEntity("AM", "Analiza Matematyczna"); subrepo.AddNew(subject); TimeTableEntity timeTable = new TimeTableEntity("poniedziałek",clazz, subject); var model1 = new PresenceEntity(model, subject, DateTime.Now.Date, true); repo.AddNew(model1); }
public void Get_student_by_id_test() { var repo = new StudentRepository(this.context); var classRepo = new ClassRepository(context); var clazz = new ClassEntity("GR1"); classRepo.AddNew(clazz); var model = new StudentEntity("Aneta", "Dams", clazz, true); var model2 = new StudentEntity("Mateusz", "Brzeziński", clazz, false); repo.AddNew(model); repo.AddNew(model2); var result = repo.GetById(model2.Id); Assert.IsNotNull(result); Assert.AreEqual(model2.Id, result.Id); Assert.AreEqual(model2.Gender, result.Gender); Assert.AreEqual(model2.Name, result.Name); Assert.AreEqual(model2.Surname, result.Surname); Assert.IsNotNull(result.Class); Assert.AreEqual(model2.Class.Id, result.Class.Id); }
public void Get_all_students_by_class_test() { var repo = new StudentRepository(this.context); var classRepo = new ClassRepository(context); var clazz = new ClassEntity("GR1"); var clazz2 = new ClassEntity("GR2"); classRepo.AddNew(clazz); classRepo.AddNew(clazz2); var model = new StudentEntity("Aneta", "Dams", clazz, true); var model2 = new StudentEntity("Mateusz", "Brzeziński", clazz, false); var model3 = new StudentEntity("Joanna", "Kowalska", clazz2, true); repo.AddNew(model); repo.AddNew(model2); repo.AddNew(model3); var result = repo.GetAllByClass(clazz.Id); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual(clazz.Id, result[0].Class.Id); Assert.AreEqual(clazz.Id, result[1].Class.Id); Assert.AreEqual(model2.Id, result[0].Id); Assert.AreEqual(model.Id, result[1].Id); }
public void AddNew(StudentEntity model) { this.context.Students.InsertOnSubmit(model); this.context.SubmitChanges(); }