Exemple #1
0
        /// <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 Address object from dictionary content
        /// </summary>
        /// <param name="dic">Dictionary with values for fields</param>
        /// <returns>New Address object</returns>
        public object ToObject(Dictionary<string, object> dic)
        {
            Mock.PhoneBook.Address p = new Mock.PhoneBook.Address();
            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>("addressvalue", out buf))
                throw new FormatException("AddressValue is incorrect or missing");

            p.AddressValue = buf;

            return p;
        }
Exemple #3
0
 /// <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();
 }