SVN钩子(hooks)的使用集-(保持SVN用例的同步)

 /// <summary>
        /// 用例消息处理
        /// </summary>
        public void TaskCaseAsk(TestActionRequestMessage request)
        {
            try
            {
                taskCaseList.Clear();
                IList<TestCase> lstcase = ScriptCacheManager.GetTestCaseFromSvn(request.SvnProjectInfo);
                );
            }
            catch (Exception ex)
            {
                TaskCaseResponse(request.DBName, taskCaseList, false, ex.Message);
            }
        }

SolutionMessage.TaskCase

 /// <summary>
        /// 从SVN服务器下载脚本项目数据。
        /// </summary>
        /// <param name="project"></param>
        /// <param name="cachePath"></param>
        public static IList<TestCase> GetTestCaseFromSvn(SvnProjectInfo project)
        {
            using (SvnClient client = new SvnClient())
            {
                Uri testCaseUrl;
                if (!Uri.TryCreate(new Uri(project.SvnUrl), "./Properties/TestCases.tcx", out testCaseUrl))
                    return null;

                client.Authentication.DefaultCredentials = new NetworkCredential(project.SvnUsername, project.SvnPassword);
                client.Authentication.SslServerTrustHandlers += new EventHandler<SharpSvn.Security.SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers);
                SvnRevision revision = (project.SvnRevision < 0) ? SvnRevision.Head : new SvnRevision(project.SvnRevision);
                SvnUriTarget repos = new SvnUriTarget(testCaseUrl.AbsoluteUri, revision);

                MemoryStream stream = new MemoryStream();
                client.Write(repos, stream);
                stream.Seek(0, SeekOrigin.Begin);
                return TestCaseDocument.FromXml(null, stream);
            }
        }

 

posted @ 2013-01-08 10:28  乡香田甜  阅读(269)  评论(0编辑  收藏  举报