/// <summary> /// Creates a Person from filled mocks /// </summary> /// <param name="person">Person mock</param> /// <param name="phone">Phone mock</param> /// <param name="address">Address mock</param> internal Person(Mock.PhoneBook.Person person, Mock.PhoneBook.Phone phone, Mock.PhoneBook.Address address) { person.AssignTo(m_personMock); phone.AssignTo(m_phoneMock); address.AssignTo(m_addressMock); if (person.isNull) person = new Mock.PhoneBook.Person(); if (phone.isNull) phone = new Mock.PhoneBook.Phone(); if (address.isNull) address = new Mock.PhoneBook.Address(); }
/// <summary> /// Makes Phone object from dictionary content /// </summary> /// <param name="dic">Dictionary with values for fields</param> /// <returns>New Phone object</returns> public object ToObject(Dictionary<string, object> dic) { Mock.PhoneBook.Phone p = new Mock.PhoneBook.Phone(); ConvertDictionary converter = dic as ConvertDictionary; int id = 0; string buf; if (!converter.TryGet<int>("phone_id", out id)) throw new FormatException("ID is incorrect or missing"); p.ID = id; if (!converter.TryGet<int>("personid", out id)) throw new FormatException("PersonID is incorrect or missing"); p.PersonID = id; if (!converter.TryGet<string>("phonevalue", out buf)) throw new FormatException("phonevalue is incorrect or missing"); p.PhoneValue = buf; return p; }
/// <summary> /// Creates a new Person /// </summary> public Person() { m_personMock = new Mock.PhoneBook.Person(); m_phoneMock = new Mock.PhoneBook.Phone(); m_addressMock = new Mock.PhoneBook.Address(); }