private void btnAdd_Click(object sender, EventArgs e) { object data = new DnsResourceDataDomainName(new DnsDomainName(txtData.Text)); if (cmbDataType.SelectedIndex == 1) { data = new DnsResourceDataIpV4(new IpV4Address(txtData.Text)); } else if (cmbDataType.SelectedIndex == 2) { data = new DnsResourceDataIpV6(new IpV6Address(txtData.Text)); } DnsDataResourceRecord record = new DnsDataResourceRecord( new DnsDomainName(txtDomainName.Text), (DnsType)Enum.Parse(typeof(DnsType), cmbType.SelectedItem.ToString()), (DnsClass)Enum.Parse(typeof(DnsClass), cmbClass.SelectedItem.ToString()) , int.Parse(txtTTL.Text), (DnsResourceData)data); tabDNS.addToAnswers(record); this.Close(); }
public void DnsResourceDataDomainNameParseWrongLengthTest() { var resourceData = new DnsResourceDataDomainName(new DnsDomainName("pcapdot.net")); TestResourceRecordIsNotCreatedWithNewLength(DnsType.Ns, resourceData, 1); TestResourceRecordIsNotCreatedWithNewLength(DnsType.Ns, resourceData, -1); }