public void newGroup_UpdatePupil_updatesPupilDetails() { Group newGroup = new Group(); newGroup.AddPupil(eddy); eddy.FirstName = "Freddy"; newGroup.UpdatePupil(eddy); PupilGroup groupEddy = newGroup.PupilGroups.ToList().FirstOrDefault(g => g.PupilId == eddy.PupilId); Assert.Equal("Freddy", groupEddy.Pupil.FirstName); }
public void UpdatePupil(Pupil pupil) { PupilGroup oldPupil = null; if (pupil.PupilId != 0) { oldPupil = PupilGroups.SingleOrDefault(p => p.PupilId == pupil.PupilId); oldPupil.Pupil.FirstName = pupil.FirstName; oldPupil.Pupil.Surname = pupil.Surname; } else { PupilGroups.Add(new PupilGroup() { Group = this, GroupId = this.GroupId, Pupil = pupil }); } }