Exemple #1
0
 public async Task <Result> CreateAsync(string domainName, DNSRecordCollection records, GoDaddyAuthenticationDetails authentication, CancellationToken cancellation)
 {
     if (records.Any())
     {
         IEnumerable <GoDaddyCreateDNSRecordRequest> recordRequests = _mapper.Map <IEnumerable <GoDaddyCreateDNSRecordRequest> >(records);
         GoDaddyCreateDNSRecordsRequest request = new GoDaddyCreateDNSRecordsRequest(authentication.ApiKey, authentication.ApiSecret, recordRequests, domainName);
         return(await _client.CreateDNSRecordsAsync(request, cancellation));
     }
     return(Result.Ok());
 }
Exemple #2
0
        public async Task Records_Are_Created_And_Successful_Result_Returned()
        {
            IGoDaddyClient fakeClient = A.Fake <IGoDaddyClient>();

            A.CallTo(() => fakeClient.CreateDNSRecordsAsync(A <GoDaddyCreateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok());

            GoDaddyDNSRecordCreator creator    = new GoDaddyDNSRecordCreator(fakeClient, _mapper);
            DNSRecordCollection     dnsRecords = new DNSRecordCollection(
                new DNSRecord
            {
                Type = DNSRecordType.A
            },
                new DNSRecord
            {
                Type = DNSRecordType.A
            });
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails(string.Empty, string.Empty);

            Result result = await creator.CreateAsync(string.Empty, dnsRecords, authicationDetails, CancellationToken.None);

            Assert.True(result.IsSuccess);
            A.CallTo(() => fakeClient.CreateDNSRecordsAsync(A <GoDaddyCreateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).MustHaveHappenedOnceExactly();
        }
Exemple #3
0
        public async Task No_Records_Are_Successfully_Created_Returns_Failure()
        {
            IGoDaddyClient fakeClient = A.Fake <IGoDaddyClient>();

            A.CallTo(() => fakeClient.CreateDNSRecordsAsync(A <GoDaddyCreateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Fail("oops"));

            GoDaddyDNSRecordCreator creator    = new GoDaddyDNSRecordCreator(fakeClient, _mapper);
            DNSRecordCollection     dnsRecords = new DNSRecordCollection(
                new DNSRecord
            {
                Type = DNSRecordType.A
            },
                new DNSRecord
            {
                Type = DNSRecordType.A
            });
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails(string.Empty, string.Empty);

            Result result = await creator.CreateAsync(string.Empty, dnsRecords, authicationDetails, CancellationToken.None);

            Assert.True(result.IsFailed);
        }