Skip to content

Commit a68be5f

Browse files
committed
made inspection resource tests independent of current culture
1 parent f15cf4e commit a68be5f

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

RubberduckTests/Inspections/GeneralInspectionTests.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
5+
using System.Threading;
46
using Microsoft.VisualStudio.TestTools.UnitTesting;
57
using Rubberduck.Inspections;
8+
using Rubberduck.UI;
69

710
namespace RubberduckTests.Inspections
811
{
912
[TestClass]
1013
public class GeneralInspectionTests
1114
{
15+
[TestInitialize]
16+
public void InitResources()
17+
{
18+
// ensure resources are using an invariant culture.
19+
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
20+
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
21+
InspectionsUI.Culture = Thread.CurrentThread.CurrentUICulture;
22+
RubberduckUI.Culture = Thread.CurrentThread.CurrentUICulture;
23+
}
24+
1225
[TestMethod]
1326
public void InspectionNameStringsExist()
1427
{
1528
var inspections = typeof(InspectionBase).Assembly.GetTypes()
1629
.Where(type => type.BaseType == typeof(InspectionBase))
1730
.Where(i => string.IsNullOrEmpty(InspectionsUI.ResourceManager.GetString(i.Name + "Name")))
18-
.Select(i => i.Name);
31+
.Select(i => i.Name)
32+
.ToList();
1933

2034
Assert.IsFalse(inspections.Any(), string.Join(Environment.NewLine, inspections));
2135
}
@@ -26,7 +40,8 @@ public void InspectionMetaStringsExist()
2640
var inspections = typeof(InspectionBase).Assembly.GetTypes()
2741
.Where(type => type.BaseType == typeof(InspectionBase))
2842
.Where(i => string.IsNullOrEmpty(InspectionsUI.ResourceManager.GetString(i.Name + "Meta")))
29-
.Select(i => i.Name);
43+
.Select(i => i.Name)
44+
.ToList();
3045

3146
Assert.IsFalse(inspections.Any(), string.Join(Environment.NewLine, inspections));
3247
}
@@ -46,7 +61,8 @@ public void InspectionResultFormatStringsExist()
4661
.Where(type => type.BaseType == typeof(InspectionBase))
4762
.Where(i => !inspectionsWithSharedResultFormat.Contains(i.Name) &&
4863
string.IsNullOrEmpty(InspectionsUI.ResourceManager.GetString(i.Name + "ResultFormat")))
49-
.Select(i => i.Name);
64+
.Select(i => i.Name)
65+
.ToList();
5066

5167
Assert.IsFalse(inspections.Any(), string.Join(Environment.NewLine, inspections));
5268
}
@@ -61,7 +77,8 @@ public void InspectionNameStrings_AreNotFormatted()
6177
var value = InspectionsUI.ResourceManager.GetString(i.Name + "Name");
6278
return !string.IsNullOrEmpty(value) && value.Contains("{0}");
6379
})
64-
.Select(i => i.Name);
80+
.Select(i => i.Name)
81+
.ToList();
6582

6683
Assert.IsFalse(inspections.Any(), string.Join(Environment.NewLine, inspections));
6784
}

0 commit comments

Comments
 (0)