Ejemplo n.º 1
0
        private static void HandleCreated(OnboardingRequest request)
        {
            if (request.Type == RequestType.CreateSPT || request.Type == RequestType.UpdateSPT)
            {
                SystemHelpers.SaveXmlToDisk(request);
                SystemHelpers.AddFileToDepotAndPack(SystemHelpers.GenerateFilename(request));

                // Create a code review.
                var codeFlowId = CodeFlowHelpers.CreateReview(_rClient, request.CreatedBy,
                                                              MembershipCheckHelpers.GetName(request.CreatedBy),
                                                              MembershipCheckHelpers.GetEmailAddress(request.CreatedBy), SystemHelpers.GenerateReivewName(request),
                                                              Constants.ProjectShortName);
                // Assign ReviewId to the corresponding field in OnboardingRequest
                request.CodeFlowId = codeFlowId;
                // Create a code package and add it to the review
                CodeFlowHelpers.AddCodePackage(_rClient, request.CodeFlowId,
                                               CodeFlowHelpers.CreateCodePackage("testing pack", request.CreatedBy, request.CreatedBy,
                                                                                 CodePackageFormat.SourceDepotPack,
                                                                                 new Uri(Constants.DepotPath + SystemHelpers.GenerateFilename(request) + ".dpk")));
                // Add reviewers to the review
                CodeFlowHelpers.AddReviewers(_rClient, request.CodeFlowId, new Reviewer[]
                {
                    CodeFlowHelpers.CreateReviewer(request.CreatedBy, MembershipCheckHelpers.GetName(request.CreatedBy),
                                                   MembershipCheckHelpers.GetEmailAddress(request.CreatedBy), true)
                });
                // Publish the review
                CodeFlowHelpers.PublishReview(_rClient, request.CodeFlowId, "meesage from author");
                Logger.Info("Code review with id [" + request.CodeFlowId + "] has been published");
                // Change State from "Created" to "PendingReview"
                request.State = RequestState.PendingReview;
                Logger.Info("Change the state of request with id [" + request.RequestId + "] to [PendingReview]");
                // Revert file to clean the changelist
                SystemHelpers.RevertFile(SystemHelpers.GenerateFilename(request));
            }
        }
Ejemplo n.º 2
0
        public void AddFileToDepotAndPackTest()
        {
            var xmlPath = Constants.DepotPath + SystemHelpers.GenerateFilename(_request);
            var dpkPath = Constants.DepotPath + SystemHelpers.GenerateFilename(_request) + ".dpk";

            Assert.IsFalse(File.Exists(dpkPath));
            SystemHelpers.SaveXmlToDisk(_request);
            SystemHelpers.AddFileToDepotAndPack(SystemHelpers.GenerateFilename(_request));
            Assert.IsTrue(File.Exists(dpkPath));
            while (true)
            {
                if (File.Exists(xmlPath) && File.Exists(dpkPath))
                {
                    File.Delete(xmlPath);
                    File.Delete(dpkPath);
                    break;
                }
            }
            SystemHelpers.RevertFile(SystemHelpers.GenerateFilename(_request));
        }