Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 2a9e4dd

Browse files
Using a desiger to better control properties
1 parent 0db9892 commit 2a9e4dd

File tree

2 files changed

+49
-27
lines changed

2 files changed

+49
-27
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
using GitHub.Models;
3+
using GitHub.ViewModels.GitHubPane;
4+
5+
namespace GitHub.SampleData
6+
{
7+
[ExcludeFromCodeCoverage]
8+
public sealed class PullRequestAnnotationItemViewModelDesigner : IPullRequestAnnotationItemViewModel
9+
{
10+
public CheckRunAnnotationModel Annotation { get; set; }
11+
public bool IsExpanded { get; set; }
12+
public string LineDescription => $"{Annotation.StartLine}:{Annotation.EndLine}";
13+
}
14+
}

src/GitHub.App/SampleData/PullRequestAnnotationsViewModelDesigner.cs

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,41 @@ public sealed class PullRequestAnnotationsViewModelDesigner : PanePageViewModelB
2020
public string CheckRunName { get; } = "Psuedo Check Run";
2121
public IReadOnlyList<IPullRequestAnnotationItemViewModel> Annotations { get; } = new[]
2222
{
23-
new PullRequestAnnotationItemViewModel(new CheckRunAnnotationModel
24-
{
25-
AnnotationLevel = CheckAnnotationLevel.Notice,
26-
StartLine = 3,
27-
EndLine = 4,
28-
Path = "asdf/asdf.cs",
29-
Message = "; is expected",
30-
Title = "CS 12345"
31-
}),
32-
new PullRequestAnnotationItemViewModel(new CheckRunAnnotationModel
33-
{
34-
AnnotationLevel = CheckAnnotationLevel.Warning,
35-
StartLine = 3,
36-
EndLine = 4,
37-
Path = "asdf/asdf.cs",
38-
Message = "; is expected",
39-
Title = "CS 12345"
40-
}),
41-
new PullRequestAnnotationItemViewModel(new CheckRunAnnotationModel
42-
{
43-
AnnotationLevel = CheckAnnotationLevel.Failure,
44-
StartLine = 3,
45-
EndLine = 4,
46-
Path = "blah.cs",
47-
Message = "; is expected",
48-
Title = "CS 12345"
49-
})
23+
new PullRequestAnnotationItemViewModelDesigner{
24+
Annotation = new CheckRunAnnotationModel
25+
{
26+
AnnotationLevel = CheckAnnotationLevel.Notice,
27+
StartLine = 3,
28+
EndLine = 4,
29+
Path = "asdf/asdf.cs",
30+
Message = "; is expected",
31+
Title = "CS 12345"
32+
},
33+
IsExpanded = true,
34+
},
35+
new PullRequestAnnotationItemViewModelDesigner{
36+
Annotation = new CheckRunAnnotationModel
37+
{
38+
AnnotationLevel = CheckAnnotationLevel.Warning,
39+
StartLine = 3,
40+
EndLine = 4,
41+
Path = "asdf/asdf.cs",
42+
Message = "; is expected",
43+
Title = "CS 12345"
44+
},
45+
IsExpanded = true
46+
},
47+
new PullRequestAnnotationItemViewModelDesigner{
48+
Annotation = new CheckRunAnnotationModel
49+
{
50+
AnnotationLevel = CheckAnnotationLevel.Failure,
51+
StartLine = 3,
52+
EndLine = 4,
53+
Path = "blah.cs",
54+
Message = "; is expected",
55+
Title = "CS 12345"
56+
}
57+
}
5058
};
5159

5260
public Task InitializeAsync(ILocalRepositoryModel localRepository, IConnection connection, string owner, string repo,

0 commit comments

Comments
 (0)