public InlineAnnotationViewModelDesigner() { var checkRunAnnotationModel = new CheckRunAnnotationModel { AnnotationLevel = CheckAnnotationLevel.Failure, Path = "SomeFile.cs", EndLine = 12, StartLine = 12, Message = "Some Error Message", Title = "CS12345" }; var checkRunModel = new CheckRunModel { Annotations = new List <CheckRunAnnotationModel> { checkRunAnnotationModel }, Name = "Fake Check Run" }; var checkSuiteModel = new CheckSuiteModel() { ApplicationName = "Fake Check Suite", HeadSha = "ed6198c37b13638e902716252b0a17d54bd59e4a", CheckRuns = new List <CheckRunModel> { checkRunModel } }; Model = new InlineAnnotationModel(checkSuiteModel, checkRunModel, checkRunAnnotationModel); }
/// <summary> /// Initializes a <see cref="InlineAnnotationViewModel"/>. /// </summary> /// <param name="model">The inline annotation model.</param> public InlineAnnotationViewModel(InlineAnnotationModel model) { Model = model; }
static IPullRequestSessionFile CreateSessionFile(bool withComments = true, bool withAnnotations = false) { var diffChunk = new DiffChunk { Lines = { // Line numbers here are 1-based. There is an add diff entry on lines 11 and 21 // and a delete entry on line 13. new DiffLine { Type = DiffChangeType.Add, NewLineNumber = 11 + 1 }, new DiffLine { Type = DiffChangeType.Delete, OldLineNumber = 13 + 1 }, new DiffLine { Type = DiffChangeType.Add, NewLineNumber = 21 + 1 }, } }; var diff = new List <DiffChunk> { diffChunk }; var file = Substitute.For <IPullRequestSessionFile>(); file.Diff.Returns(diff); if (withComments) { var rhsThread = Substitute.For <IInlineCommentThreadModel>(); rhsThread.DiffLineType.Returns(DiffChangeType.Add); rhsThread.LineNumber.Returns(10); var lhsThread = Substitute.For <IInlineCommentThreadModel>(); lhsThread.DiffLineType.Returns(DiffChangeType.Delete); lhsThread.LineNumber.Returns(12); // We have a comment to display on the right-hand-side of the diff view on line // 11 and a comment to display on line 13 on the left-hand-side. var threads = new List <IInlineCommentThreadModel> { rhsThread, lhsThread }; file.InlineCommentThreads.Returns(threads); } if (withAnnotations) { var annotation1 = new InlineAnnotationModel(new CheckSuiteModel(), new CheckRunModel(), new CheckRunAnnotationModel() { EndLine = 11 }); var annotation2 = new InlineAnnotationModel(new CheckSuiteModel(), new CheckRunModel(), new CheckRunAnnotationModel() { EndLine = 21 }); var annotation3 = new InlineAnnotationModel(new CheckSuiteModel(), new CheckRunModel(), new CheckRunAnnotationModel() { EndLine = 21 }); var annotations = new List <InlineAnnotationModel> { annotation1, annotation2, annotation3 }; file.InlineAnnotations.Returns(annotations); } file.LinesChanged.Returns(new Subject <IReadOnlyList <Tuple <int, DiffSide> > >()); return(file); }