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

Commit d5f71a0

Browse files
committed
Fix potential l10n problems in tests.
1 parent 7a71032 commit d5f71a0

File tree

9 files changed

+28
-20
lines changed

9 files changed

+28
-20
lines changed

test/GitHub.App.UnitTests/Collections/SequentialListSourceTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
45
using System.Reactive;
56
using System.Reactive.Linq;
@@ -105,7 +106,7 @@ protected override string CreateViewModel(string model)
105106

106107
protected override async Task<Page<string>> LoadPage(string after)
107108
{
108-
var page = after != null ? int.Parse(after) : 0;
109+
var page = after != null ? int.Parse(after, CultureInfo.InvariantCulture) : 0;
109110

110111
if (loadTrigger != null)
111112
{
@@ -121,7 +122,7 @@ protected override async Task<Page<string>> LoadPage(string after)
121122

122123
return new Page<string>
123124
{
124-
EndCursor = (page + 1).ToString(),
125+
EndCursor = (page + 1).ToString(CultureInfo.InvariantCulture),
125126
HasNextPage = page < PageCount,
126127
Items = Enumerable.Range(page * PageSize, PageSize).Select(x => "Item " + x).ToList(),
127128
TotalCount = PageSize * PageCount,

test/GitHub.App.UnitTests/Services/AvatarProviderTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using NSubstitute;
1313
using UnitTests.Helpers;
1414
using NUnit.Framework;
15+
using System.Globalization;
1516

1617
public class AvatarProviderTests
1718
{
@@ -25,14 +26,14 @@ public async Task CanBeAccessedFromMultipleThreadsAsync()
2526
sharedCache.LocalMachine.Returns(blobCache);
2627
var imageCache = new TestImageCache();
2728
var avatarProvider = new AvatarProvider(sharedCache, imageCache);
28-
var expected = avatarProvider.DefaultOrgBitmapImage.ToString();
29+
var expected = avatarProvider.DefaultOrgBitmapImage.ToString(CultureInfo.InvariantCulture);
2930
int mainThreadId = Thread.CurrentThread.ManagedThreadId;
3031
int otherThreadId = mainThreadId;
3132

3233
var actual = await Task.Run(() =>
3334
{
3435
otherThreadId = Thread.CurrentThread.ManagedThreadId;
35-
return avatarProvider.DefaultOrgBitmapImage.ToString();
36+
return avatarProvider.DefaultOrgBitmapImage.ToString(CultureInfo.InvariantCulture);
3637
});
3738

3839
Assert.That(expected, Is.EqualTo(actual));
@@ -50,14 +51,14 @@ public async Task CanBeAccessedFromMultipleThreadsAsync()
5051
sharedCache.LocalMachine.Returns(blobCache);
5152
var imageCache = new TestImageCache();
5253
var avatarProvider = new AvatarProvider(sharedCache, imageCache);
53-
var expected = avatarProvider.DefaultUserBitmapImage.ToString();
54+
var expected = avatarProvider.DefaultUserBitmapImage.ToString(CultureInfo.InvariantCulture);
5455
int mainThreadId = Thread.CurrentThread.ManagedThreadId;
5556
int otherThreadId = mainThreadId;
5657

5758
var actual = await Task.Run(() =>
5859
{
5960
otherThreadId = Thread.CurrentThread.ManagedThreadId;
60-
return avatarProvider.DefaultUserBitmapImage.ToString();
61+
return avatarProvider.DefaultUserBitmapImage.ToString(CultureInfo.InvariantCulture);
6162
});
6263

6364
Assert.That(expected, Is.EqualTo(actual));
@@ -130,7 +131,7 @@ public class TheInvalidateAvatarMethod : TestBaseClass
130131
public void DoesNotThrowOnNullUserOrAvatarUrl()
131132
{
132133
var blobStore = Substitute.For<IBlobCache>();
133-
blobStore.Invalidate(null).Returns(_ => { throw new ArgumentNullException(); });
134+
blobStore.Invalidate(null).Returns(_ => { throw new ArgumentNullException("key"); });
134135
var sharedCache = Substitute.For<ISharedCache>();
135136
sharedCache.LocalMachine.Returns(blobStore);
136137

test/GitHub.Exports.UnitTests/UriStringTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public class TheEqualsMethod : TestBaseClass
298298
[TestCase("https://github.com/foo/bar", null, false)]
299299
public void ReturnsTrueForCaseSensitiveEquality(string source, string compare, bool expected)
300300
{
301-
Assert.That(expected, Is.EqualTo(source.Equals(compare)));
301+
Assert.That(expected, Is.EqualTo(source.Equals(compare, StringComparison.Ordinal)));
302302
Assert.That(expected, Is.EqualTo(EqualityComparer<UriString>.Default.Equals(source, compare)));
303303
}
304304

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

Lines changed: 2 additions & 1 deletion
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.Linq;
45
using GitHub.InlineReviews.Services;
@@ -89,7 +90,7 @@ IEnumerable<InlineCommentModel> CreateComments(params string[] bodies)
8990

9091
foreach (var body in bodies)
9192
{
92-
yield return CreateComment((id++).ToString(), body);
93+
yield return CreateComment((id++).ToString(CultureInfo.InvariantCulture), body);
9394
}
9495
}
9596

test/GitHub.VisualStudio.UnitTests/Commands/OpenFromClipboardCommandTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Globalization;
23
using System.Threading.Tasks;
34
using GitHub;
45
using GitHub.Exports;
@@ -43,7 +44,7 @@ public async Task NoLocalRepository()
4344
public async Task UnknownLinkType()
4445
{
4546
var context = new GitHubContext { LinkType = LinkType.Unknown };
46-
var expectMessage = string.Format(Resources.UnknownLinkTypeMessage, context.Url);
47+
var expectMessage = string.Format(CultureInfo.InvariantCulture, Resources.UnknownLinkTypeMessage, context.Url);
4748
var activeRepositoryDir = "activeRepositoryDir";
4849
var vsServices = Substitute.For<IVSServices>();
4950
var target = CreateOpenFromClipboardCommand(vsServices: vsServices, contextFromClipboard: context, repositoryDir: activeRepositoryDir);
@@ -68,7 +69,7 @@ public async Task DifferentLocalRepository(string targetRepositoryName, string a
6869

6970
if (expectMessage != null)
7071
{
71-
vsServices.Received(1).ShowMessageBoxInfo(string.Format(expectMessage, context.RepositoryName));
72+
vsServices.Received(1).ShowMessageBoxInfo(string.Format(CultureInfo.InvariantCulture, expectMessage, context.RepositoryName));
7273
}
7374
else
7475
{

test/Helpers/RepositoryHelpers.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using LibGit2Sharp;
22
using System;
33
using System.Collections.Generic;
4+
using System.Globalization;
45
using System.IO;
56
using System.Linq;
67
using System.Reflection;
@@ -49,6 +50,6 @@ public static void AddGitLinkToTheIndex(Index index, string path, string sha)
4950
var id = new ObjectId(sha);
5051
var mode = Mode.GitLink;
5152
index.GetType().InvokeMember("AddEntryToTheIndex", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null,
52-
index, new object[] { path, id, mode });
53+
index, new object[] { path, id, mode }, CultureInfo.InvariantCulture);
5354
}
5455
}

test/TrackingCollectionTests/TestBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections;
3+
using System.Globalization;
34
using System.Reactive.Subjects;
45
using System.Text;
56

@@ -41,8 +42,8 @@ protected void Dump(string msg)
4142

4243
protected void Dump(object prefix, object thing)
4344
{
44-
output?.WriteLine(string.Format("{0} - {1}", prefix, thing));
45-
testOutput.AppendLine(string.Format("{0} - {1}", prefix, thing));
45+
output?.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} - {1}", prefix, thing));
46+
testOutput.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0} - {1}", prefix, thing));
4647
}
4748

4849
protected void Dump(object thing)

test/TrackingCollectionTests/Thing.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using GitHub.Collections;
22
using System;
33
using System.ComponentModel;
4+
using System.Globalization;
45

56
public class Thing : ICopyable<Thing>, IEquatable<Thing>, IComparable<Thing>, INotifyPropertyChanged
67
{
@@ -105,7 +106,7 @@ void OnPropertyChanged(string propertyName)
105106

106107
public override string ToString()
107108
{
108-
return string.Format("id:{0} title:{1} created:{2:u} updated:{3:u}", Number, Title, CreatedAt, UpdatedAt);
109+
return string.Format(CultureInfo.InvariantCulture, "id:{0} title:{1} created:{2:u} updated:{3:u}", Number, Title, CreatedAt, UpdatedAt);
109110
}
110111

111112
public int CompareTo(Thing other)

test/TrackingCollectionTests/TrackingCollectionTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Threading.Tasks;
1515
using System.Reactive.Threading.Tasks;
1616
using GitHub;
17+
using System.Globalization;
1718

1819
[TestFixture]
1920
public class TrackingTests : TestBase
@@ -333,7 +334,7 @@ public void FilterTitleRun2()
333334
ITrackingCollection<Thing> col = new TrackingCollection<Thing>(
334335
list1.ToObservable(),
335336
OrderedComparer<Thing>.OrderByDescending(x => x.UpdatedAt).Compare,
336-
(item, position, list) => item.Title.Equals("Run 2"));
337+
(item, position, list) => item.Title.Equals("Run 2", StringComparison.Ordinal));
337338
col.NewerComparer = OrderedComparer<Thing>.OrderByDescending(x => x.UpdatedAt).Compare;
338339
col.ProcessingDelay = TimeSpan.Zero;
339340

@@ -378,7 +379,7 @@ public void OrderByDoesntMatchOriginalOrderTimings()
378379
ITrackingCollection<Thing> col = new TrackingCollection<Thing>(
379380
list1.ToObservable(),
380381
OrderedComparer<Thing>.OrderByDescending(x => x.UpdatedAt).Compare,
381-
(item, position, list) => item.Title.Equals("Run 2"));
382+
(item, position, list) => item.Title.Equals("Run 2", StringComparison.Ordinal));
382383
col.NewerComparer = OrderedComparer<Thing>.OrderByDescending(x => x.UpdatedAt).Compare;
383384
col.ProcessingDelay = TimeSpan.Zero;
384385

@@ -430,7 +431,7 @@ public void OrderByMatchesOriginalOrder()
430431
ITrackingCollection<Thing> col = new TrackingCollection<Thing>(
431432
list1.ToObservable(),
432433
OrderedComparer<Thing>.OrderByDescending(x => x.UpdatedAt).Compare,
433-
(item, position, list) => item.Title.Equals("Run 2"));
434+
(item, position, list) => item.Title.Equals("Run 2", StringComparison.Ordinal));
434435
col.NewerComparer = OrderedComparer<Thing>.OrderByDescending(x => x.UpdatedAt).Compare;
435436
col.ProcessingDelay = TimeSpan.Zero;
436437

@@ -1881,14 +1882,14 @@ public async Task MultipleSortingAndFiltering()
18811882

18821883
var list1 = Observable.Defer(() => Enumerable.Range(1, expectedTotal)
18831884
.OrderBy(rnd.Next)
1884-
.Select(x => GetThing(x, x, x, ((char)('a' + x)).ToString()))
1885+
.Select(x => GetThing(x, x, x, ((char)('a' + x)).ToString(CultureInfo.InvariantCulture)))
18851886
.ToObservable())
18861887
.Replay()
18871888
.RefCount();
18881889

18891890
var list2 = Observable.Defer(() => Enumerable.Range(1, expectedTotal)
18901891
.OrderBy(rnd.Next)
1891-
.Select(x => GetThing(x, x, updatedAtMinutesStack.Pop(), ((char)('c' + x)).ToString()))
1892+
.Select(x => GetThing(x, x, updatedAtMinutesStack.Pop(), ((char)('c' + x)).ToString(CultureInfo.InvariantCulture)))
18921893
.ToObservable())
18931894
.Replay()
18941895
.RefCount();

0 commit comments

Comments
 (0)