public DigitalOceanDomainProcessor(IDNSRecordCollectionMutator dnsRecordMutator, IDigitalOceanDNSRecordCreator dnsRecordCreator, IDigitalOceanDNSRecordReader dnsRecordReader, IDigitalOceanDNSRecordUpdater dnsRecordUpdater)
 {
     _dnsRecordMutator = dnsRecordMutator;
     _dnsRecordCreator = dnsRecordCreator;
     _dnsRecordReader  = dnsRecordReader;
     _dnsRecordUpdater = dnsRecordUpdater;
 }
        public async Task ReturnsFailureWhenUpdateFails()
        {
            DNSRecordCollection dnsRecordCollection = DNSRecordCollection.Empty();
            DigitalOceanDomain  domain          = new DigitalOceanDomain();
            ExternalAddress     externalAddress = new ExternalAddress();

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

            A.CallTo(() => dnsRecordMutator.Mutate(A <DNSRecordCollection> .Ignored, A <IDNSRecordCollectionMutation> .Ignored)).Returns(dnsRecordCollection);

            IDigitalOceanDNSRecordCreator dnsRecordCreator = A.Fake <IDigitalOceanDNSRecordCreator>();

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

            IDigitalOceanDNSRecordReader dnsRecordReader = A.Fake <IDigitalOceanDNSRecordReader>();

            A.CallTo(() => dnsRecordReader.ReadAsync(A <DigitalOceanDomain> .Ignored, A <string> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok(dnsRecordCollection));

            IDigitalOceanDNSRecordUpdater dnsRecordUpdater = A.Fake <IDigitalOceanDNSRecordUpdater>();

            A.CallTo(() => dnsRecordUpdater.UpdateAsync(A <string> .Ignored, A <DNSRecordCollection> .Ignored, A <string> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Fail("Error."));

            IDigitalOceanDomainProcessor processor = new DigitalOceanDomainProcessor(dnsRecordMutator, dnsRecordCreator, dnsRecordReader, dnsRecordUpdater);
            Result result = await processor.ProcessAsync(domain, externalAddress, string.Empty, new CancellationToken());

            Assert.True(result.IsFailed);
        }