Exemple #1
0
        public async Task Returns_Success_When_All_Records_Update()
        {
            IGoDaddyClient client = A.Fake <IGoDaddyClient>();

            A.CallTo(() => client.UpdateDNSRecordAsync(A <GoDaddyUpdateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok());

            GoDaddyDNSRecordUpdater      updater            = new GoDaddyDNSRecordUpdater(client, _mapper);
            DNSRecordCollection          records            = new DNSRecordCollection(CreateValidDNSRecord(1), CreateValidDNSRecord(2));
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails("apiKey", "apiSecret");

            Result result = await updater.UpdateAsync("aDomain.com", records, authicationDetails, CancellationToken.None);

            Assert.True(result.IsSuccess);
        }
Exemple #2
0
        public async Task <Result> UpdateAsync(string domainName, DNSRecordCollection records, GoDaddyAuthenticationDetails authentication, CancellationToken cancellation)
        {
            Result result = Result.Ok();

            foreach (DNSRecord record in records)
            {
                GoDaddyUpdateDNSRecord         mappedRecord = _mapper.Map <GoDaddyUpdateDNSRecord>(record);
                GoDaddyUpdateDNSRecordsRequest request      = new GoDaddyUpdateDNSRecordsRequest(authentication.ApiKey, authentication.ApiSecret, domainName, record.Type, record.Name, mappedRecord);
                Result updateResult = await _client.UpdateDNSRecordAsync(request, cancellation);

                result = result.Merge(updateResult);
            }
            return(result);
        }
Exemple #3
0
        public async Task No_Records_Are_Successfully_Created_If_Client_Fails()
        {
            IGoDaddyClient client = A.Fake <IGoDaddyClient>();

            A.CallTo(() => client.UpdateDNSRecordAsync(A <GoDaddyUpdateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Fail("Error"));

            GoDaddyDNSRecordUpdater      updater            = new GoDaddyDNSRecordUpdater(client, _mapper);
            DNSRecordCollection          records            = new DNSRecordCollection(CreateValidDNSRecord(1), CreateValidDNSRecord(2));
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails("apiKey", "apiSecret");

            Result result = await updater.UpdateAsync("aDomain.com", records, authicationDetails, CancellationToken.None);

            Assert.True(result.IsFailed);
            Assert.Equal(2, result.Errors.Count);
        }