示例#1
0
        public void UpdateStudent_EditElementStudentInXML()
        {
            //Arrange
            StudentsContext context = new StudentsContext();

            Student student = new Student()
            {
                Id        = 9,
                FirstName = "Smit",
                Last      = "Robenson",
                Age       = "32",
                Gender    = "0"
            };

            //act
            context.UpdateStudent(student);

            //Assert
            var element = context.xDoc.Root.Elements("Student").Select(s => s).Where(s => (int)s.Attribute("Id") == 9)
                          .First();

            Assert.IsTrue(element.Element("FirstName").Value == student.FirstName);
            Assert.IsTrue(element.Element("Last").Value == student.Last);
            Assert.IsTrue(element.Element("Age").Value == student.Age);
            Assert.IsTrue(element.Element("Gender").Value == student.Gender);
        }