public override int ExecuteAndReturn()
        {
            Guard.AssertNotNull(this.CurrentWork);
            //return Handle_GithubRepositoriesWithIssues<IssueEvent>(this.CurrentWork, this.PersistLastSnapshot, base.Logger);
            return(HandleWork <IssueEvent>(this.Console, this.CurrentWork, this.Logger, (w, i) =>
            {
                string key = w.GetKey(i);

                return CreateEvents(key, (sf) =>
                {
                    return IssueListSnapshotBuilder.CreateFileSnapshotFromRequest(sf, ExtractIssuesByRepositoryPath(w.AccessToken, i));
                }
                                    , (sf2) =>
                {
                    bool exists = w.Repository.TryPull(key, sf2);
                    this.Logger.LogTrace("GetLastSnapshot.SnapshotFilename={0} (Exists={1})", key, exists);
                    if (exists)
                    {
                        ITableSnapshotBuilder builder = IssueListSnapshotBuilder.CreateFromFile(sf2);
                        return builder;
                    }
                    else
                    {
                        return IssueListSnapshotBuilder.EmptySnapshot();
                    }
                }
                                    , w.Repository, this.PersistLastSnapshot, this.Logger, (dr, et)
                                    => EventFactory.CreateIssueEvent(dr, et)
                                    );
            }));
        }
        public void Base_JsonInterpreter()
        {
            int counter = 0;

            foreach (var tpl in IssueListSnapshotBuilder.ExtractIssueNodes("myAccount", "myRepo", new string[] { Resources.GetIssuesResponse_FirstDraft() }))
            {
                TextWriter.Null.WriteLine(tpl.Item2);
                counter += 1;
            }
            Assert.Equal(15, counter); //adjusted from 20 to 15 at 11.08.2015
        }
Beispiel #3
0
        [InlineData("Dotnet", "core")] //small repo
        //[InlineData("Microsoft", "vscode")]
        public void Issue_Snapshot_from_Web(string owner, string repo)
        {
            ITableSnapshotBuilder builder;

            Assert.True(this.Extractor.MaximumNodesCountPerRequest > 50);
            builder = IssueListSnapshotBuilder.CreateInMemorySnapshotFromRequest(this.Extractor.GetIssueMetadataAsynch(this.Token, owner, repo).Result);
            using (ITableSnapshot snapshot = builder.Build())
            {
                using (var reader = snapshot.GetDataReader())
                {
                    while (reader.Read())
                    {
                        EventFactory.CreateIssueEvent(reader, EventType.Created);
                    }
                }
            }
        }
Beispiel #4
0
        public void Extract_Issues_By_Repo(string owner, string repo)
        {
            int    counter = 0;
            string ts      = DateTime.Now.ToString("yyyyMMddHHmmss");

            this.Extractor.MaximumNodesCountPerRequest = 15;
            foreach (string json in this.Extractor.GetIssueMetadataAsynch(this.Token, owner, repo).Result)
            {
                string fn       = string.Format("Issues_{0}_{1}_{2}.json", ts, counter, owner);
                string fullName = Path.Combine(this.TargetDirectory, fn);
                File.WriteAllText(fullName, json);
                int cnt = System.Linq.Enumerable.Count(IssueListSnapshotBuilder.ExtractIssueNodes(owner, repo, new string[] { json }));
                Assert.Equal(this.Extractor.MaximumNodesCountPerRequest, cnt);
                counter += 1;
                if (counter > 2)
                {
                    break;
                }
            }
        }
 public void Base_Builder()
 {
     ITableSnapshot snapshot = IssueListSnapshotBuilder.CreateInMemorySnapshotFromRequest(new string[] { Resources.GetIssuesResponse_FirstDraft() }).Build();
 }