public void SaveGodaddyAccount(DAS.Domain.GoDaddy.Users.GoDaddyAccount account) { var acc = new GoDaddyAccount(); var godaddy = Context.GoDaddyAccount.ToList(); acc.FromDomainObject(account); var existingAccount = Context.GoDaddyAccount.FirstOrDefault(x => x.GoDaddyUsername == account.Username); if (existingAccount != null) { acc.AccountID = Context.Users.First(x => x.Username == account.Username).UserID; Context.GoDaddyAccount.AddOrUpdate(acc); } else { existingAccount = new GoDaddyAccount { GoDaddyPassword = account.Password, Verified = account.Verified, GoDaddyUsername = account.Username, AccountID = account.AccountId, UserID = account.UserID }; Context.GoDaddyAccount.AddOrUpdate(existingAccount); } Context.Save(); }
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 ProcessAsync_AnyAccountsReturnFailureResult_ReturnsFailureResult() { ExternalAddress externalAddress = new ExternalAddress() { IPv4Address = IPAddress.Parse("100.100.100.100") }; GoDaddyAccount accountOne = new GoDaddyAccount(); GoDaddyAccount accountTwo = new GoDaddyAccount(); GoDaddyConfiguration config = new GoDaddyConfiguration() { Accounts = new List <GoDaddyAccount>() { accountOne, accountTwo } }; IOptionsSnapshot <GoDaddyConfiguration> optionsSnapshot = A.Fake <IOptionsSnapshot <GoDaddyConfiguration> >(); IGoDaddyAccountProcessor accountProcessor = A.Fake <IGoDaddyAccountProcessor>(); A.CallTo(() => optionsSnapshot.Value).Returns(config); A.CallTo(() => accountProcessor.ProcessAsync(accountOne, externalAddress, A <CancellationToken> .Ignored)).Returns(Result.Ok()); A.CallTo(() => accountProcessor.ProcessAsync(accountTwo, externalAddress, A <CancellationToken> .Ignored)).Returns(Result.Fail("This failed")); GoDaddyDDNSService DOService = new GoDaddyDDNSService(accountProcessor, optionsSnapshot); Result actual = await DOService.ProcessAsync(externalAddress, new CancellationToken()); Assert.True(actual.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 void Validate_MissingDomains_ReturnsIsNotValid() { GoDaddyAccount account = new GoDaddyAccount() { ApiKey = "ApiKey", ApiSecret = "ApiSecret" }; IValidator <GoDaddyAccount> validator = new GoDaddyAccountValidator(); ValidationResult result = validator.Validate(account); Assert.False(result.IsValid); }
public void Validate_ValidAccount_ReturnsIsValid() { GoDaddyAccount account = new GoDaddyAccount() { ApiKey = "ApiKey", ApiSecret = "ApiSecret", Domains = CreateValidGoDaddyDomains() }; IValidator <GoDaddyAccount> validator = new GoDaddyAccountValidator(); ValidationResult result = validator.Validate(account); Assert.True(result.IsValid); }
protected void btnSave_Godaddy(object sender, EventArgs e) { if (IsPostBack) { using (var ds = new ASEntities()) { if (GdAccount == null) { var account = new GoDaddyAccount { GoDaddyUsername = inputEmail3.Text, GoDaddyPassword = inputPassword3.Text, UserID = Account.UserID }; ds.GoDaddyAccount.Add(account); ds.SaveChanges(); } } } }
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); }
public void SaveGodaddyAccount(DAS.Domain.GoDaddy.Users.GoDaddyAccount account) { var acc = new GoDaddyAccount(); var godaddy = Context.GoDaddyAccount.ToList(); acc.FromDomainObject(account); var existingAccount = Context.GoDaddyAccount.FirstOrDefault(x => x.GoDaddyUsername == account.Username); if (existingAccount != null) { acc.AccountID = Context.Users.First(x=>x.Username == account.Username).UserID; Context.GoDaddyAccount.AddOrUpdate(acc); } else { existingAccount = new GoDaddyAccount { GoDaddyPassword = account.Password, Verified = account.Verified, GoDaddyUsername = account.Username, AccountID = account.AccountId, UserID = account.UserID }; Context.GoDaddyAccount.AddOrUpdate(existingAccount); } Context.Save(); }