public async Task ProcessAsync_AnyFailReturnsFailureResult() { GoDaddyDomain domainOne = new GoDaddyDomain(); GoDaddyDomain domainTwo = new GoDaddyDomain(); IGoDaddyDomainProcessor domainProcessor = A.Fake <IGoDaddyDomainProcessor>(); A.CallTo(() => domainProcessor.ProcessAsync(domainOne, A <ExternalAddress> .Ignored, A <GoDaddyAuthenticationDetails> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok()); A.CallTo(() => domainProcessor.ProcessAsync(domainTwo, A <ExternalAddress> .Ignored, A <GoDaddyAuthenticationDetails> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Fail("This failed")); GoDaddyAccountProcessor processor = new GoDaddyAccountProcessor(domainProcessor); GoDaddyAccount account = new GoDaddyAccount() { Domains = new List <GoDaddyDomain>() { domainOne, domainTwo } }; ExternalAddress externalAddress = new ExternalAddress() { IPv4Address = IPAddress.Parse("100.100.100.100") }; Result result = await processor.ProcessAsync(account, externalAddress, new CancellationToken()); Assert.True(result.IsFailed); }
public async Task <Result> ProcessAsync(GoDaddyAccount account, ExternalAddress externalAddress, CancellationToken cancellation) { Result result = Result.Ok(); GoDaddyAuthenticationDetails authenticationDetails = new GoDaddyAuthenticationDetails(account.ApiKey, account.ApiSecret); foreach (GoDaddyDomain domain in account.Domains) { result = result.Merge(await _domainProcessor.ProcessAsync(domain, externalAddress, authenticationDetails, cancellation)); } return(result); }
public async Task ProcessAsync_AllSucceed_ReturnsSuccessfulResult() { IGoDaddyDomainProcessor domainProcessor = A.Fake <IGoDaddyDomainProcessor>(); A.CallTo(() => domainProcessor.ProcessAsync(A <GoDaddyDomain> .Ignored, A <ExternalAddress> .Ignored, A <GoDaddyAuthenticationDetails> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok()); GoDaddyAccountProcessor processor = new GoDaddyAccountProcessor(domainProcessor); GoDaddyAccount account = new GoDaddyAccount() { Domains = new List <GoDaddyDomain>() { new GoDaddyDomain(), new GoDaddyDomain() } }; ExternalAddress externalAddress = new ExternalAddress() { IPv4Address = IPAddress.Parse("100.100.100.100") }; Result result = await processor.ProcessAsync(account, externalAddress, new CancellationToken()); Assert.True(result.IsSuccess); }