Account IAccountHelper.CreateBy(Type connectionType, string connectionAccountName, string token) { //创建随机账号 var account = new Account("a" + DateTime.Now.ToString("yyyyMMddHHmmss") + _rd.Next(10, 100));//TODO:随机数方式修改或改为guid this._accountService.Create(account); //创建连接 AccountConnection connection = null; if (connectionType == typeof(GoogleConnection)) connection = new GoogleConnection(connectionAccountName, token, account); else if (connectionType == typeof(GitHubConnection)) connection = new GitHubConnection(connectionAccountName, token, account); else connection = this.GenerateConnection(account, connectionType, connectionAccountName, token); //指定令牌 connection.SetToken(token); this._connectionService.Create(connection); if (this._log.IsInfoEnabled) this._log.InfoFormat("根据连接{0}|{1}创建账号#{2}" , connectionType , connectionAccountName , account.ID); return account; }
public void CreateGit() { var u = this.RandomString(); var c = new GitHubConnection(u, _token, this.CreateAccount()); this._accountConnectionService.Create(c); Assert.Greater(c.ID, 0); var c2 = this._accountConnectionService.GetConnection<GitHubConnection>(u); Assert.IsNotNull(c2); Assert.AreEqual(c2.ID, c.ID); Assert.AreEqual(c2.Name, c.Name); }