コード例 #1
0
		public void SoaRecord_OptionalParams()
		{
			// Arrange
			string nameParam = "agreatexample.com";
			int timeToLiveParam = 3600;
			string nameServerParam = "ns1.agreatexample.com";
			string responsiblePersonParam = "john.smith.agreatexample.com";
			int refreshParam = 43200;
			int retryParam = 180;
			int expiryParam = 1209600;
			int negativeCachingTtlParam = 10800;
			string recordClassParam = "CH";
			uint serialNumberParam = 4294967295;

			// Act
			_soaRecord = new SoaRecord(
				name: nameParam,
				timeToLive: timeToLiveParam,
				nameServer: nameServerParam,
				responsiblePerson: responsiblePersonParam,
				refresh: refreshParam,
				retry: retryParam,
				expiry: expiryParam,
				negativeCachingTtl: negativeCachingTtlParam,
				serialNumber: serialNumberParam,
				recordClass: recordClassParam
			);

			// Assert
			_soaRecord.RecordClass.Should().Be(recordClassParam);
			_soaRecord.SerialNumber.Should().Be(serialNumberParam);
		}
コード例 #2
0
		public void SoaRecord_NoOptionalParameters()
		{
			// Arrange
			string nameParam = "agreatexample.com";
			int timeToLiveParam = 3600;
			string nameServerParam = "ns1.agreatexample.com";
			string responsiblePersonParam = "john.smith.agreatexample.com";
			int refreshParam = 43200;
			int retryParam = 180;
			int expiryParam = 1209600;
			int negativeCachingTtlParam = 10800;

			// Act
			_soaRecord = new SoaRecord(
				name: nameParam,
				timeToLive: timeToLiveParam,
				nameServer: nameServerParam,
				responsiblePerson: responsiblePersonParam,
				refresh: refreshParam,
				retry: retryParam,
				expiry: expiryParam,
				negativeCachingTtl: negativeCachingTtlParam
			);

			// Assert
			_soaRecord.Name.Should().Be(nameParam);
			_soaRecord.TimeToLive.Should().Be(timeToLiveParam);
			_soaRecord.NameServer.Should().Be(nameServerParam);
			_soaRecord.ResponsiblePerson.Should().Be(responsiblePersonParam);
			_soaRecord.Refresh.Should().Be(refreshParam);
			_soaRecord.Retry.Should().Be(retryParam);
			_soaRecord.Expiry.Should().Be(expiryParam);
			_soaRecord.NegativeCachingTtl.Should().Be(negativeCachingTtlParam);

			_soaRecord.RecordClass.Should().Be("IN");
			_soaRecord.RecordType.Should().Be(RecordType.SOA);
		}
コード例 #3
0
		public void WriteZoneFile()
		{
			// Arrange
			var zoneFilePath = Path.GetTempFileName();
			var expected = Resources.ZoneFileExample1;
			var soaRecord = new SoaRecord("example.com", 3600, "ns1.example.com", "john.smith.example.com", 3600, 4500, 5700, 2200);
			var nsRecords = new[] {
				new NsRecord("example.com", 3600, "ns1.example.com"),
				new NsRecord("example.com", 4200, "ns2.example.com")
			};
			var aRecords = new[] {
				new ARecord("example.com", 3600, "10.4.12.24"),
				new ARecord("ns1.example.com", 4200, "10.4.12.25"),
				new ARecord("ns2.example.com", 4700, "10.4.12.26"),
				new ARecord("mx1.example.com", 5000, "10.4.12.27")
			};
			var mxRecords = new[] {
				new MxRecord("example.com", 2700, "mx1.example.com")
			};
			var aaaaRecords = new[] {
				new AAAARecord("new.example.com", 6000, "2001:0db8:85a3:0000:0000:8a2e:0370:7334")
			};

			var zone = new Zone();
			zone.SoaRecord = soaRecord;
			zone.ARecords = aRecords;
			zone.NsRecords = nsRecords;
			zone.MxRecords = mxRecords;
			zone.AaaaRecords = aaaaRecords;

			// Act
			zone.Write(zoneFilePath);

			// Assert
			var actual = File.ReadAllText(zoneFilePath);
			actual.Should().Be(expected);
		}
コード例 #4
0
		public void SoaRecord_ToRecordString()
		{
			// Arrange
			_soaRecord = new SoaRecord(
				name: "exampledomain.net",
				timeToLive: 3600,
				nameServer: "ns1.exampledomain.net",
				responsiblePerson: "bob.baker.exampledomain.net",
				refresh: 43200,
				retry: 180,
				expiry: 1209600,
				negativeCachingTtl: 10800
			);

			// Act
			string recordString = _soaRecord.ToRecordString();

			// Assert
			recordString.Should().Match(Resources.SoaRecordString);
		}