コード例 #1
0
        public void ReturnsNewDomainRecordRequestWhenNull()
        {
            DNSRecordToDigitalOceanCreateDomainRecordRequestConverter converter = new DNSRecordToDigitalOceanCreateDomainRecordRequestConverter();
            DNSRecord record = new DNSRecord()
            {
                Data     = "DNSData",
                Flags    = 1,
                Name     = "DNSName",
                Port     = 1,
                Priority = 1,
                Tag      = "DNSTag",
                TTL      = 1,
                Weight   = 1,
                Type     = DNSRecordType.A
            };

            DigitalOceanCreateDomainRecordRequest actual = converter.Convert(record, null, _mappingHelper.ResolutionContext);

            Assert.Equal(record.Data, actual.Data);
            Assert.Equal(record.Flags, actual.Flags);
            Assert.Equal(record.Name, actual.Name);
            Assert.Equal(record.Port, actual.Port);
            Assert.Equal(record.Priority, actual.Priority);
            Assert.Equal(record.Tag, actual.Tag);
            Assert.Equal(record.TTL, actual.Ttl);
            Assert.Equal(record.Weight, actual.Weight);
            Assert.Equal(DNSRecordType.A.Value, actual.Type);
        }
コード例 #2
0
        public async Task <Result> CreateDNSRecordAsync(string domainName, DigitalOceanCreateDomainRecordRequest request, string token, CancellationToken cancellation)
        {
            string         path        = string.Format(_createDNSRecordFormat, domainName);
            IFlurlRequest  httpRequest = BuildRequest(token, path);
            IFlurlResponse response    = await httpRequest.PostJsonAsync(request, cancellation);

            if (response.ResponseMessage.IsSuccessStatusCode)
            {
                return(Result.Ok().WithSuccess(string.Format(_createDNSRecordSuccessMessageTemplate, domainName, request.Name)));
            }
            return(Result.Fail(string.Format(_createDNSRecordFailureMessageTemplate, domainName, request.Name)));
        }
コード例 #3
0
        public async Task Create_Failure_Is_Fail_Result()
        {
            _httpTest.RespondWith(string.Empty, (int)HttpStatusCode.BadRequest);
            IDigitalOceanClient client = new DigitalOceanClient(_httpClient);

            DigitalOceanCreateDomainRecordRequest request = new DigitalOceanCreateDomainRecordRequest
            {
                Data = "100.100.100.100",
                Name = "test",
                Ttl  = 1800,
                Type = DNSRecordType.A
            };

            Result response = await client.CreateDNSRecordAsync("test.com", request, string.Empty, CancellationToken.None);

            Assert.True(response.IsFailed);
        }
コード例 #4
0
        public void OverwirtesCreateDomainRecordRequestValues()
        {
            DNSRecordToDigitalOceanCreateDomainRecordRequestConverter converter = new DNSRecordToDigitalOceanCreateDomainRecordRequestConverter();
            DNSRecord record = new DNSRecord()
            {
                Data     = "DNSData",
                Flags    = 1,
                Name     = "DNSName",
                Port     = 1,
                Priority = 1,
                Tag      = "DNSTag",
                TTL      = 1,
                Weight   = 1,
                Type     = DNSRecordType.A
            };

            DigitalOceanCreateDomainRecordRequest createRecord = new DigitalOceanCreateDomainRecordRequest()
            {
                Data     = "CreatData",
                Flags    = 123,
                Name     = "CreateName",
                Port     = 123,
                Priority = 123,
                Tag      = "DNSTag",
                Ttl      = 123,
                Weight   = 123,
                Type     = "Some other type"
            };

            DigitalOceanCreateDomainRecordRequest actual = converter.Convert(record, createRecord, _mappingHelper.ResolutionContext);

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