public void GivenNoCachedCommentExists_WhenWeAsForComments_ThenTheyAreRetrieved()
 {
     var commentsCache = new CommentsCache();
     var tfsJsonBuilds = GetTfsJsonBuilds(1, 2);
     commentsCache.FetchNewComments(tfsJsonBuilds, new TfsConnectionDetails(), GetCommentFunc("some comment")).Wait();
     Assert.AreEqual("some comment", commentsCache.GetCachedCommentForBuild(tfsJsonBuilds[0]));
 }
 public void GivenOldCachedCommentExists_WhenBuildIdHasNotChanged_ThenNewCommentsAreNotRetrieved()
 {
     var commentsCache = new CommentsCache();
     var tfsJsonBuilds = GetTfsJsonBuilds(1, 2);
     commentsCache.FetchNewComments(tfsJsonBuilds, new TfsConnectionDetails(), GetCommentFunc("old comment")).Wait();
     commentsCache.FetchNewComments(tfsJsonBuilds, new TfsConnectionDetails(), GetCommentFunc("new comment")).Wait();
     Assert.AreEqual("old comment", commentsCache.GetCachedCommentForBuild(tfsJsonBuilds[0]));
 }
 public TfsRestBuildStatus(TfsJsonBuild tfsRestBuildDefinition, CommentsCache commentsCache)
 {
     BuildStatusEnum   = GetBuildStatus(tfsRestBuildDefinition);
     Name              = tfsRestBuildDefinition.Definition.Name;
     BuildDefinitionId = tfsRestBuildDefinition.Definition.Id.ToString();
     RequestedBy       = tfsRestBuildDefinition.RequestedFor?.DisplayName;
     BuildId           = tfsRestBuildDefinition.Id.ToString();
     Url     = tfsRestBuildDefinition._links.Web.Href;
     Comment = commentsCache.GetCachedCommentForBuild(tfsRestBuildDefinition);
 }
 public TfsRestBuildStatus(TfsJsonBuild tfsRestBuildDefinition, CommentsCache commentsCache)
 {
     BuildStatusEnum = GetBuildStatus(tfsRestBuildDefinition);
     Name = tfsRestBuildDefinition.Definition.Name;
     BuildDefinitionId = tfsRestBuildDefinition.Definition.Id.ToString();
     RequestedBy = tfsRestBuildDefinition.RequestedFor.DisplayName;
     BuildId = tfsRestBuildDefinition.Id.ToString();
     Url = tfsRestBuildDefinition._links.Web.Href;
     Comment = commentsCache.GetCachedCommentForBuild(tfsRestBuildDefinition);
 }
        private CommentsCache GetCommentsCache(int buildDefinitionId, int buildId, string comment)
        {
            var commentsCache = new CommentsCache();

            var projects = GetTfsJsonBuilds(buildDefinitionId, buildId);
            commentsCache.FetchNewComments(projects, new TfsConnectionDetails(), GetCommentFunc(comment)).Wait();
            return commentsCache;
        }