Beispiel #1
0
 /// <summary>
 /// Adds person to the people collection
 /// </summary>
 /// <param name="person"></param>
 /// <returns>Person added</returns>
 public Person addPerson(Person person)
 {
     string index = maxPersonIndex;
     person.id = index;
     people.Add(index, person);
     return person;
 }
Beispiel #2
0
 public Person(Person person)
 {
     firstName = person.firstName;
     lastName = person.lastName;
     telephoneNumber = person.telephoneNumber;
     id = person.id;
 }
Beispiel #3
0
        public void TestGetPersonWithID()
        {
            People people = new People();
            Person person = new Person();

            people.addPerson(person);
            Assert.AreSame(person, people.getPerson(person.id).Item2);
        }
Beispiel #4
0
 /// <summary>
 /// Adds a person given the firstName lastName and telephoneNumber
 /// </summary>
 /// <param name="firstName"></param>
 /// <param name="lastName"></param>
 /// <param name="telephoneNumber"></param>
 /// <returns>Person added</returns>
 public Person addPerson(string firstName, string lastName, string telephoneNumber)
 {
     //DRY
     Person person = new Person(firstName, lastName, telephoneNumber);
     return this.addPerson(person);
     /*string index = maxPersonIndex;
     person.id = index;
     people.Add(index, person);*/
     //return person;
 }
Beispiel #5
0
        public void TestGetPerson()
        {
            People people = new People();
            Person person = new Person("c", "c", "c");

            people.addPerson(person);
            Person result = people.getPerson(person);

            Assert.AreSame(person, result);
        }
Beispiel #6
0
 public void TestExistsIdLarge()
 {
     People people = new People();
     for (int i = 0; i < 100000; i++)
     {
         people.addPerson("", "", "");
     }
     Person person = new Person();
     person = people.addPerson(person);
     Assert.IsTrue(people.existsPerson(person.id));
 }
Beispiel #7
0
 static void changeInfo(Person person)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
 /// <summary>
 /// Removes person from the people dictionary
 /// </summary>
 /// <param name="person"></param>
 static void removePerson(Person person)
 {
     if(people.existsPerson(person))
         people.removePerson(person);
 }
Beispiel #9
0
 /// <summary>
 /// Takes person and lists its information
 /// </summary>
 /// <param name="person"></param>
 static void listPerson(Person person)
 {
     Console.WriteLine(person);
 }
Beispiel #10
0
 /// <summary>
 /// Checks if person is in the dictionary or not
 /// </summary>
 /// <param name="person"></param>
 /// <returns>true if people contains specific person</returns>
 public bool existsPerson(Person person)
 {
     return people.ContainsValue(person);
       //  return people.Any(p => p.Value == person);
 }
Beispiel #11
0
 /// <summary>
 /// Removes person from the dictionary
 /// It's totally safe to remove something that isn't in the dictionary in the first place
 /// </summary>
 /// <param name="person">Person to remove</param>
 public void removePerson(Person person)
 {
     people.Remove(person.id);
 }
Beispiel #12
0
 public Person getPerson(Person person)
 {
     return people.Single(p => p.Key == person.id).Value;
 }
Beispiel #13
0
 public string getId(Person person)
 {
     return people.Single(p => p.Value == person).Key;
 }
Beispiel #14
0
        public void TestGetPersonWithIDFail()
        {
            People people = new People();
            Person person = new Person();

            people.addPerson(person);

            Assert.AreEqual(false, people.getPerson(2).Item1);
        }
Beispiel #15
0
        public void TestRemovePerson()
        {
            People people = new People();
            Person person = new Person("Christoffer", "Holmgren", "07382344460");

            people.addPerson(person);
            Assert.IsTrue(people.existsPerson(person));

            people.removePerson(person);
            Assert.IsFalse(people.existsPerson(person));
        }