public void SaveData() { //Contacts1 contacts1 = new Contacts1() { Name = "waef" }; //FileStream fileStream = new FileStream("data.dat", FileMode.Create, FileAccess.Write); //BinaryFormatter binaryFormatter = new BinaryFormatter(); //binaryFormatter.Serialize(fileStream, contacts1); Contacts contacts = new Contacts(); Group group1 = new Group(); string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; group1.AddPerson(person1); Assert.AreEqual(1, group1.Amount); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group1.AddPerson(person2); Group group2 = new Group(); string name3 = "chao"; string company3 = "ynu"; string position3 = "graduate"; Person person3 = new Person { Name = name3, Company = company3, Position = position3 }; group2.AddPerson(person3); Group group3 = new Group(); string name4 = "maichao"; string company4 = "ynu"; string position4 = "student"; Person person4 = new Person { Name = name4, Company = company4, Position = position4 }; group3.AddPerson(person4); Assert.AreEqual(1, group3.Amount); string name5 = "mai"; string company5 = "ynu"; string position5 = "graduate"; Person person5 = new Person { Name = name5, Company = company5, Position = position5 }; group3.AddPerson(person5); string name = "maimai"; string company = "ynu"; string position = "graduate"; Person person = new Person { Name = name, Company = company, Position = position }; group1.AddPerson(person); group2.AddPerson(person); group3.AddPerson(person); contacts.AddGroup(group1); contacts.AddGroup(group2); contacts.AddGroup(group3); FileStream fileStream = new FileStream("data.dat", FileMode.Create, FileAccess.Write); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(fileStream, person1); //BinaryDataAccess bda = new BinaryDataAccess(); //bda.SaveData(contacts, "data.dat"); }
public void ContactsAdd() { Contacts contacts = new Contacts(); Group group1 = new Group(); string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; group1.AddPerson(person1); Assert.AreEqual(1, group1.Amount); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group1.AddPerson(person2); Group group2 = new Group(); string name3 = "chao"; string company3 = "ynu"; string position3 = "graduate"; Person person3 = new Person { Name = name3, Company = company3, Position = position3 }; group2.AddPerson(person3); Group group3 = new Group(); string name4 = "maichao"; string company4 = "ynu"; string position4 = "student"; Person person4 = new Person { Name = name4, Company = company4, Position = position4 }; group3.AddPerson(person4); Assert.AreEqual(1, group3.Amount); string name5 = "mai"; string company5 = "ynu"; string position5 = "graduate"; Person person5 = new Person { Name = name5, Company = company5, Position = position5 }; group3.AddPerson(person5); contacts.AddGroup(group1); contacts.AddGroup(group2); contacts.AddGroup(group3); Assert.AreEqual(4, contacts.GroupsAmount); Assert.AreEqual(5, contacts.PersonsAmount); }
public void ContactsNew() { Contacts contacts = new Contacts(); Assert.IsNotNull(contacts); Assert.AreEqual(1, contacts.GroupsAmount); Assert.AreEqual(0, contacts.PersonsAmount); }
public void ContactsSearchGroup() { Contacts contacts = new Contacts(); string name1 ="family"; string name2 ="work"; string name3 ="other"; Group group1 = new Group() { Name = name1 }; Group group2 = new Group() { Name = name2 }; Group group3 = new Group() { Name = name3 }; contacts.AddGroup(group1); contacts.AddGroup(group2); contacts.AddGroup(group3); var res = contacts.SearchGroup("work"); Assert.AreEqual(1, res.Count); }
public Services() { contacts = new Contacts(); this.LoadContacts(); }