public void CreateStudent_AddNewStudentElementInXML() { //arrrange StudentsContext context = new StudentsContext(); int maxId = context.xDoc.Root.Elements("Student").Max(s => (int)s.Attribute("Id")); Student newStudent = new Student() { Id = ++maxId, FirstName = "Smit", Last = "Uilson", Age = "32", Gender = "0" }; //Act context.CreateStudent(newStudent); bool exist = context.xDoc.Root.Elements("Student").Any(s => (int)s.Attribute("Id") == newStudent.Id); //Assert Assert.IsTrue(exist); }