public void CreateStudent() { var users = new Repositories.UserRepository(_context); var students = new Repositories.StudentRepository(_context); var name = new Models.Name { FirstName = "Trine", LastName = "Thune" }; var student = new Models.Student { Username = "******", Password = "******", Approved = false, Name = name, HomeRoomClass = _context.HomeRoomClasses.SingleOrDefault(h => h.Name == "dat12x") }; students.InsertOnSubmit(student); _context.SubmitChanges(); var actualUser = (users.Single(u => u.Id == student.UserId)); var actualStudent = (students.Single(s => s == student)); Assert.IsNotNull(actualUser); Assert.IsInstanceOfType(actualUser, typeof(Models.User)); Assert.IsNotNull(actualStudent); Assert.IsInstanceOfType(actualStudent, typeof(Models.Student)); Assert.AreEqual(actualStudent, student); Assert.IsNotNull(actualStudent.Name); Assert.IsInstanceOfType(actualStudent.Name, typeof(Models.Name)); Assert.AreEqual(name, actualStudent.Name); }
public void GetStudents() { var homeRoomClassName = "Dat12x"; var students = new Repositories.StudentRepository(_context); var actualStudent = students.Single(s => s.HomeRoomClass.Name == homeRoomClassName); Assert.IsNotNull(actualStudent); Assert.IsInstanceOfType(actualStudent, typeof(Models.Student)); Assert.AreEqual(homeRoomClassName, actualStudent.HomeRoomClass.Name); }