public void PersonDataClassTest() { var person1 = new PersonDataClass() { Name = "John", Age = 25 }; var person2 = new PersonDataClass() { Name = "Paul", Age = 36 }; person2 = person1; person2.Age = 30; /*Now both persons age have been changed by assigning a new value for age of person2, * as a RefType is used here (Objects)*/ Assert.AreEqual(person1.Age, person2.Age); }
/////////////////////////////////////////////////////////////////////// /// Listing 6-10 public List <string> PeopleEmployeedWithinLocation_Classes(int amount, LocationClass location) { List <string> result = new List <string>(); List <PersonDataClass> input = service.GetPersonsInBatchClasses(amount); DateTime now = DateTime.Now; for (int i = 0; i < input.Count; ++i) { PersonDataClass item = input[i]; if (now.Subtract(item.BirthDate).TotalDays > 18 * 365) { var employee = service.GetEmployeeClass(item.EmployeeId); if (locationService.DistanceWithClass(location, employee.Address) < 10.0) { string name = string.Format("{0} {1}", item.Firstname, item.Lastname); result.Add(name); } } } return(result); }