public void ReturnsNewDNSRecordWhenPassedNull()
        {
            DigitalOceanGetDomainRecordResponseToDNSRecordConverter converter = new DigitalOceanGetDomainRecordResponseToDNSRecordConverter();
            DigitalOceanGetDomainRecordResponse response = new DigitalOceanGetDomainRecordResponse()
            {
                Data     = "data",
                Flags    = 1,
                Id       = 1,
                Name     = "name",
                Port     = 1,
                Priority = 1,
                Tag      = "tag",
                Ttl      = 1,
                Type     = "A",
                Weight   = 1
            };

            DNSRecord actual = converter.Convert(response, null, _mappingHelper.ResolutionContext);

            Assert.Equal(response.Data, actual.Data);
            Assert.Equal(response.Flags, actual.Flags);
            Assert.Equal(response.Id.ToString(), actual.Id);
            Assert.Equal(response.Name, actual.Name);
            Assert.Equal(response.Port, actual.Port);
            Assert.Equal(response.Priority, actual.Priority);
            Assert.Equal(response.Tag, actual.Tag);
            Assert.Equal(response.Ttl, actual.TTL);
            Assert.Equal(DNSRecordType.A, actual.Type);
            Assert.Equal(response.Weight, actual.Weight);
        }
        public async Task Read_Success_Is_Success_Result_And_Contains_DNSRecord()
        {
            _httpTest.RespondWith(_readResponse);
            IDigitalOceanClient client = new DigitalOceanClient(_httpClient);

            DigitalOceanDomain domain = new DigitalOceanDomain
            {
                Name = "test.com"
            };

            Result <DigitalOceanGetDomainRecordsResponse> response = await client.GetDNSRecordsAsync(domain, string.Empty, CancellationToken.None);

            Assert.True(response.IsSuccess);

            IList <DigitalOceanGetDomainRecordResponse> domainRecords = response.Value.DomainRecords.ToList();

            Assert.True(domainRecords.Count() == 1);

            DigitalOceanGetDomainRecordResponse dnsRecord = domainRecords.First();

            Assert.Equal("100.100.100.100", dnsRecord.Data);
            Assert.Equal(28448432, dnsRecord.Id);
            Assert.Equal("test", dnsRecord.Name);
            Assert.Equal(DNSRecordType.A, dnsRecord.Type);
        }
        public void OverwritesDNSRecordWhenPassedARecord()
        {
            DigitalOceanGetDomainRecordResponseToDNSRecordConverter converter = new DigitalOceanGetDomainRecordResponseToDNSRecordConverter();
            DigitalOceanGetDomainRecordResponse response = new DigitalOceanGetDomainRecordResponse()
            {
                Data     = "data",
                Flags    = 1,
                Id       = 1,
                Name     = "name",
                Port     = 1,
                Priority = 1,
                Tag      = "tag",
                Ttl      = 1,
                Type     = "A",
                Weight   = 1
            };
            DNSRecord record = new DNSRecord()
            {
                Data     = "dnsData",
                Flags    = 987,
                Id       = "aDNSRecordId",
                Name     = "aDNSRecordName",
                Port     = 852,
                Priority = 42,
                Tag      = "aDNSTag",
                TTL      = 987,
                Type     = DNSRecordType.CERT,
                Weight   = 42
            };

            DNSRecord actual = converter.Convert(response, record, _mappingHelper.ResolutionContext);

            Assert.Equal(response.Data, actual.Data);
            Assert.Equal(response.Flags, actual.Flags);
            Assert.Equal(response.Id.ToString(), actual.Id);
            Assert.Equal(response.Name, actual.Name);
            Assert.Equal(response.Port, actual.Port);
            Assert.Equal(response.Priority, actual.Priority);
            Assert.Equal(response.Tag, actual.Tag);
            Assert.Equal(response.Ttl, actual.TTL);
            Assert.Equal(DNSRecordType.A, actual.Type);
            Assert.Equal(response.Weight, actual.Weight);
        }