public void should_correctly_prepare_record_type(RecordType type, string expected)
        {
            var dto = new ZoneRecordRequest
            {
                Data       = Data,
                Name       = Name,
                RecordType = type,
                Ttl        = 7200,
            };

            var json = dto.Prepare();

            json.ShouldContain(expected);
        }
        public void should_correctly_prepare_full_dto()
        {
            var dto = new ZoneRecordRequest
            {
                Data       = Data,
                Name       = Name,
                RecordType = RecordType.A,
                Ttl        = 7200
            };

            var json = dto.Prepare();

            json.ShouldContain(Data);
            json.ShouldContain(Name);
            json.ShouldContain("A");
            json.ShouldContain("7200");
            json.ShouldNotContain("aux");
            json.ShouldNotContain(Aux);
        }
        public void should_correctly_prepare_dto_with_aux()
        {
            var dto = new ZoneRecordRequest
            {
                Data       = Data,
                Name       = Name,
                RecordType = RecordType.Mx,
                Ttl        = 7200,
                Aux        = Aux
            };

            var json = dto.Prepare();

            json.ShouldContain(Data);
            json.ShouldContain(Name);
            json.ShouldContain("MX");
            json.ShouldContain("7200");
            json.ShouldContain(Aux);
        }
Пример #4
0
        public async Task <ZoneRecord> CreateRecordAsync(int zoneId, string name, RecordType type, string data,
                                                         int ttl, string aux = null)
        {
            var dto = new ZoneRecordRequest
            {
                Aux        = aux,
                Data       = data,
                Name       = name,
                RecordType = type,
                Ttl        = ttl
            };

            var response = await _client.Post($"{BaseUrl}/{zoneId}/records", dto.Prepare());

            ErrorHandler(response.StatusCode);

            var content = await response.Content.ReadAsStringAsync();

            var responseDto = JsonConvert.DeserializeObject <ZoneRecordResponse>(content);

            return(responseDto.ZoneRecord);
        }