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

Commit 55d6564

Browse files
committed
Fix various CA warnings in tests.
1 parent 428ddd7 commit 55d6564

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

test/GitHub.App.UnitTests/ViewModels/PullRequestReviewCommentThreadViewModelTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Globalization;
23
using System.Linq;
34
using System.Reactive.Concurrency;
45
using System.Reactive.Linq;
@@ -66,7 +67,7 @@ public async Task PostsCommentInReplyToCorrectComment()
6667
target.Comments[2].Body = "New Comment";
6768
await target.Comments[2].CommitEdit.Execute();
6869

69-
session.Received(1).PostReviewComment("New Comment", "1");
70+
await session.Received(1).PostReviewComment("New Comment", "1");
7071
}
7172

7273
[Test]
@@ -158,18 +159,18 @@ IEnumerable<InlineCommentModel> CreateComments(params string[] bodies)
158159

159160
foreach (var body in bodies)
160161
{
161-
yield return CreateComment((id++).ToString(), body);
162+
yield return CreateComment((id++).ToString(CultureInfo.InvariantCulture), body);
162163
}
163164
}
164165

165-
IPullRequestSessionFile CreateFile(string relativePath = "file.cs")
166+
static IPullRequestSessionFile CreateFile(string relativePath = "file.cs")
166167
{
167168
var result = Substitute.For<IPullRequestSessionFile>();
168169
result.RelativePath.Returns(relativePath);
169170
return result;
170171
}
171172

172-
IViewViewModelFactory CreateFactory()
173+
static IViewViewModelFactory CreateFactory()
173174
{
174175
var result = Substitute.For<IViewViewModelFactory>();
175176
var commentService = Substitute.For<ICommentService>();
@@ -178,7 +179,7 @@ IViewViewModelFactory CreateFactory()
178179
return result;
179180
}
180181

181-
IPullRequestSession CreateSession()
182+
static IPullRequestSession CreateSession()
182183
{
183184
var result = Substitute.For<IPullRequestSession>();
184185
result.User.Returns(new ActorModel { Login = "Viewer" });

test/GitHub.InlineReviews.UnitTests/ViewModels/InlineCommentPeekViewModelTests.cs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,7 @@ void AddCommentToExistingThread(IPullRequestSessionFile file)
255255
RaiseLinesChanged(file, Tuple.Create(thread.LineNumber, DiffSide.Right));
256256
}
257257

258-
IApiClientFactory CreateApiClientFactory()
259-
{
260-
var apiClient = Substitute.For<IApiClient>();
261-
apiClient.CreatePullRequestReviewComment(null, null, 0, null, 0)
262-
.ReturnsForAnyArgs(_ => Observable.Return(new PullRequestReviewComment()));
263-
apiClient.CreatePullRequestReviewComment(null, null, 0, null, null, null, 0)
264-
.ReturnsForAnyArgs(_ => Observable.Return(new PullRequestReviewComment()));
265-
266-
var result = Substitute.For<IApiClientFactory>();
267-
result.Create(null).ReturnsForAnyArgs(apiClient);
268-
return result;
269-
}
270-
271-
InlineCommentModel CreateComment(string body)
258+
static InlineCommentModel CreateComment(string body)
272259
{
273260
return new InlineCommentModel
274261
{
@@ -280,7 +267,7 @@ InlineCommentModel CreateComment(string body)
280267
};
281268
}
282269

283-
IViewViewModelFactory CreateFactory()
270+
static IViewViewModelFactory CreateFactory()
284271
{
285272
var draftStore = Substitute.For<IMessageDraftStore>();
286273
var commentService = Substitute.For<ICommentService>();
@@ -292,7 +279,7 @@ IViewViewModelFactory CreateFactory()
292279
return result;
293280
}
294281

295-
IInlineCommentThreadModel CreateThread(int lineNumber, params string[] comments)
282+
static IInlineCommentThreadModel CreateThread(int lineNumber, params string[] comments)
296283
{
297284
var result = Substitute.For<IInlineCommentThreadModel>();
298285
var commentList = comments.Select(x => CreateComment(x)).ToList();
@@ -301,14 +288,14 @@ IInlineCommentThreadModel CreateThread(int lineNumber, params string[] comments)
301288
return result;
302289
}
303290

304-
IInlineCommentPeekService CreatePeekService(int lineNumber)
291+
static IInlineCommentPeekService CreatePeekService(int lineNumber)
305292
{
306293
var result = Substitute.For<IInlineCommentPeekService>();
307294
result.GetLineNumber(null, null).ReturnsForAnyArgs(Tuple.Create(lineNumber, false));
308295
return result;
309296
}
310297

311-
IPeekSession CreatePeekSession()
298+
static IPeekSession CreatePeekSession()
312299
{
313300
var document = Substitute.For<ITextDocument>();
314301
document.FilePath.Returns(FullPath);
@@ -322,7 +309,7 @@ IPeekSession CreatePeekSession()
322309
return result;
323310
}
324311

325-
IPullRequestSession CreateSession()
312+
static IPullRequestSession CreateSession()
326313
{
327314
var result = Substitute.For<IPullRequestSession>();
328315
result.PullRequest.Returns(new PullRequestDetailModel());
@@ -331,7 +318,7 @@ IPullRequestSession CreateSession()
331318
return result;
332319
}
333320

334-
IPullRequestSessionManager CreateSessionManager(
321+
static IPullRequestSessionManager CreateSessionManager(
335322
string commitSha = "COMMIT",
336323
string relativePath = RelativePath,
337324
IPullRequestSession session = null,
@@ -378,13 +365,13 @@ IPullRequestSessionManager CreateSessionManager(
378365
return result;
379366
}
380367

381-
void RaiseLinesChanged(IPullRequestSessionFile file, params Tuple<int, DiffSide>[] lineNumbers)
368+
static void RaiseLinesChanged(IPullRequestSessionFile file, params Tuple<int, DiffSide>[] lineNumbers)
382369
{
383370
var subject = (Subject<IReadOnlyList<Tuple<int, DiffSide>>>)file.LinesChanged;
384371
subject.OnNext(lineNumbers);
385372
}
386373

387-
void RaisePropertyChanged<T>(T o, string propertyName)
374+
static void RaisePropertyChanged<T>(T o, string propertyName)
388375
where T : INotifyPropertyChanged
389376
{
390377
o.PropertyChanged += Raise.Event<PropertyChangedEventHandler>(new PropertyChangedEventArgs(propertyName));

0 commit comments

Comments
 (0)