コード例 #1
0
        public async Task Returns_Success_With_DNS_Records_When_Successfully_Retrieved()
        {
            IGoDaddyClient fakeClient = A.Fake <IGoDaddyClient>();

            List <GoDaddyGetDNSRecordResponse> records = new List <GoDaddyGetDNSRecordResponse>()
            {
                CreateValidGoDaddyGetDNSRecordResponse(1),
                CreateValidGoDaddyGetDNSRecordResponse(2),
                CreateValidGoDaddyGetDNSRecordResponse(3)
            };

            GoDaddyGetDNSRecordsResponse clientResponse = new GoDaddyGetDNSRecordsResponse(records);

            A.CallTo(() => fakeClient.GetDNSRecordsAsync(A <GoDaddyGetDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok(clientResponse));
            GoDaddyDNSRecordReader       reader             = new GoDaddyDNSRecordReader(fakeClient, _mapper);
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails("apiKey", "apiSecret");

            Result <DNSRecordCollection> result = await reader.ReadAsync(string.Empty, authicationDetails, CancellationToken.None);

            DNSRecord firstRecord = result.Value.First();

            Assert.True(result.IsSuccess);
            Assert.Equal(3, result.Value.Count);

            Assert.Equal("Data-1", firstRecord.Data);
            Assert.Equal("Name-1", firstRecord.Name);
            Assert.Equal(1, firstRecord.Port);
        }
コード例 #2
0
        public async Task Returns_Failure_When_Getting_Record_Fails()
        {
            IGoDaddyClient fakeClient = A.Fake <IGoDaddyClient>();

            A.CallTo(() => fakeClient.GetDNSRecordsAsync(A <GoDaddyGetDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Fail("failed"));

            GoDaddyDNSRecordReader       reader             = new GoDaddyDNSRecordReader(fakeClient, _mapper);
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails("apiKey", "apiSecret");

            Result <DNSRecordCollection> result = await reader.ReadAsync(string.Empty, authicationDetails, CancellationToken.None);

            Assert.True(result.IsFailed);
        }