コード例 #1
0
        public void TelephoneContactConstructorTest()
        {
            TelephoneContact target = new TelephoneContact(zoneCode, contactName);

            Assert.AreEqual(zoneCode, target.ZoneCode, "Поле ZoneCode у созданного класса не совпалдет со значеним ZoneCode, переданном в параметрах");
            Assert.AreEqual(contactName, target.ContactName, "Поле contactName у созданного класса не совпалдет со значеним contactName, переданном в параметрах");
        }
コード例 #2
0
        public override int GetHashCode()
        {
            int result = 1;

            result = (result * 397) ^ (AltEmailAddress != null ? AltEmailAddress.GetHashCode() : 0);
            result = (result * 397) ^ (AltTelephoneContact != null ? AltTelephoneContact.GetHashCode() : 0);
            result = (result * 397) ^ (CreatedOn != null ? CreatedOn.GetHashCode() : 0);
            result = (result * 397) ^ (DateOfBirth != null ? DateOfBirth.GetHashCode() : 0);
            result = (result * 397) ^ (EmailAddress != null ? EmailAddress.GetHashCode() : 0);
            result = (result * 397) ^ (Gender != null ? Gender.GetHashCode() : 0);
            result = (result * 397) ^ (GivenName != null ? GivenName.GetHashCode() : 0);
            result = (result * 397) ^ (HomeLanguage != null ? HomeLanguage.GetHashCode() : 0);
            result = (result * 397) ^ Id.GetHashCode();
            result = (result * 397) ^ (LastModified != null ? LastModified.GetHashCode() : 0);
            result = (result * 397) ^ (MaritalStatus != null ? MaritalStatus.GetHashCode() : 0);
            result = (result * 397) ^ (NextOfKinAddress != null ? NextOfKinAddress.GetHashCode() : 0);
            result = (result * 397) ^ (NextOfKinContact != null ? NextOfKinContact.GetHashCode() : 0);
            result = (result * 397) ^ (NextOfKinName != null ? NextOfKinName.GetHashCode() : 0);
            result = (result * 397) ^ (NextOfKinRelationship != null ? NextOfKinRelationship.GetHashCode() : 0);
            result = (result * 397) ^ (Occupation != null ? Occupation.GetHashCode() : 0);
            result = (result * 397) ^ (Organisation != null ? Organisation.GetHashCode() : 0);
            result = (result * 397) ^ (OtherName != null ? OtherName.GetHashCode() : 0);
            result = (result * 397) ^ (PermentAddress != null ? PermentAddress.GetHashCode() : 0);
            result = (result * 397) ^ (PersonOwnerType != null ? PersonOwnerType.GetHashCode() : 0);
            result = (result * 397) ^ (PlaceOfBirth != null ? PlaceOfBirth.GetHashCode() : 0);
            result = (result * 397) ^ (PostalAddress != null ? PostalAddress.GetHashCode() : 0);
            result = (result * 397) ^ (PreferredLanguage != null ? PreferredLanguage.GetHashCode() : 0);
            result = (result * 397) ^ (ProfilePhotoName != null ? ProfilePhotoName.GetHashCode() : 0);
            result = (result * 397) ^ (Religion != null ? Religion.GetHashCode() : 0);
            result = (result * 397) ^ (Surname != null ? Surname.GetHashCode() : 0);
            result = (result * 397) ^ (TelephoneContact != null ? TelephoneContact.GetHashCode() : 0);
            result = (result * 397) ^ (Title != null ? Title.GetHashCode() : 0);
            result = (result * 397) ^ (WebsiteUrl != null ? WebsiteUrl.GetHashCode() : 0);
            return(result);
        }
コード例 #3
0
        public async Task <IActionResult> Edit(long id, [Bind("TelephoneContactId,TelephoneContact1,ApplicationId,CreatedAt")] TelephoneContact telephoneContact)
        {
            if (id != telephoneContact.TelephoneContactId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(telephoneContact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TelephoneContactExists(telephoneContact.TelephoneContactId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationId"] = new SelectList(_context.Applications, "ApplicationId", "FullName", telephoneContact.ApplicationId);
            return(View(telephoneContact));
        }
コード例 #4
0
        public void ToStringTest()
        {
            TelephoneContact target   = new TelephoneContact(zoneCode, contactName);
            string           expected = string.Format("Contact - Number: {0}, name - {1}", zoneCode, contactName);
            string           actual;

            actual = target.ToString();
            Assert.AreEqual(expected, actual, "Созданная строка отличается от ожидаемой");
        }
コード例 #5
0
        public void CompareToTest()
        {
            TelephoneContact target       = new TelephoneContact(zoneCode, contactName);
            TelephoneContact phoneContact = null;
            int actual;

            actual = target.CompareTo(phoneContact);
            Assert.IsTrue(actual == 1, "Результат сравнения некорректен");
        }
コード例 #6
0
        public void ToXmlTest()
        {
            TelephoneContact target = new TelephoneContact(zoneCode, contactName);
            var      expected       = string.Format("<Contacts>\r\n  <PhoneContacts>\r\n    <Name Value=\"{0}\" />\r\n    <ZoneCode Value=\"{1}\" />\r\n  </PhoneContacts>\r\n</Contacts>", contactName, zoneCode);
            XElement actual;

            actual = target.ToXml();
            Assert.AreEqual(expected, actual.ToString(), "Сформированное xml не соответствует ожидаемому");;
        }
コード例 #7
0
        public void ZoneCodeTest()
        {
            TelephoneContact target   = new TelephoneContact(zoneCode, contactName);
            long             expected = 0;
            long             actual;

            target.ZoneCode = expected;
            actual          = target.ZoneCode;
            Assert.AreEqual(expected, actual, "Поле ZoneCode класса TelephoneContact не изменилось");
        }
コード例 #8
0
        public void AddTelephoneContactToCardTest()
        {
            Card             target           = new Card();
            int              expectedCount    = target.ContactList.Count + 1;
            TelephoneContact telephoneContact = new TelephoneContact(111, "Test Contact");
            Card             actual;

            actual = target.AddTelephoneContactToCard(telephoneContact, target);
            int actualCount = actual.ContactList.Count;

            Assert.AreEqual(expectedCount, actualCount);
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("TelephoneContactId,TelephoneContact1,ApplicationId,CreatedAt")] TelephoneContact telephoneContact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(telephoneContact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationId"] = new SelectList(_context.Applications, "ApplicationId", "FullName", telephoneContact.ApplicationId);
            return(View(telephoneContact));
        }