示例#1
0
 public GoDaddyDomainProcessor(IGoDaddyDNSRecordCreator dnsRecordCreator, IDNSRecordCollectionMutator dnsRecordMutator, IGoDaddyDNSRecordReader dnsRecordReader, IGoDaddyDNSRecordUpdater dnsRecordUpdater)
 {
     _dnsRecordCreator = dnsRecordCreator;
     _dnsRecordMutator = dnsRecordMutator;
     _dnsRecordReader  = dnsRecordReader;
     _dnsRecordUpdater = dnsRecordUpdater;
 }
        public async Task ProcessAsync_ReadFails_ReturnsFailureResult()
        {
            IGoDaddyDNSRecordCreator dnsCreator = A.Fake <IGoDaddyDNSRecordCreator>();

            A.CallTo(() => dnsCreator.CreateAsync(A <string> .Ignored, A <DNSRecordCollection> .Ignored, A <GoDaddyAuthenticationDetails> .Ignored, A <CancellationToken> .Ignored))
            .Returns(Result.Ok());

            IDNSRecordCollectionMutator mutator = A.Fake <IDNSRecordCollectionMutator>();

            A.CallTo(() => mutator.Mutate(A <DNSRecordCollection> .Ignored, A <IDNSRecordCollectionMutation> .Ignored))
            .Returns(DNSRecordCollection.Empty());

            IGoDaddyDNSRecordReader dnsReader = A.Fake <IGoDaddyDNSRecordReader>();

            A.CallTo(() => dnsReader.ReadAsync(A <string> .Ignored, A <GoDaddyAuthenticationDetails> .Ignored, A <CancellationToken> .Ignored))
            .Returns(Result.Fail("Reader Failure"));

            IGoDaddyDNSRecordUpdater dnsUpdater = A.Fake <IGoDaddyDNSRecordUpdater>();

            A.CallTo(() => dnsUpdater.UpdateAsync(A <string> .Ignored, A <DNSRecordCollection> .Ignored, A <GoDaddyAuthenticationDetails> .Ignored, A <CancellationToken> .Ignored))
            .Returns(Result.Ok());

            IGoDaddyDomainProcessor domainProcessor = new GoDaddyDomainProcessor(dnsCreator, mutator, dnsReader, dnsUpdater);

            GoDaddyDomain domain = new GoDaddyDomain()
            {
                Name = "GoDaddy Domain"
            };
            ExternalAddress externalAddress = A.Fake <ExternalAddress>();
            GoDaddyAuthenticationDetails authenticationDetails = A.Fake <GoDaddyAuthenticationDetails>();

            Result result = await domainProcessor.ProcessAsync(domain, externalAddress, authenticationDetails, new CancellationToken());

            Assert.False(result.IsSuccess);
            Assert.True(result.IsFailed);
        }