Skip to content

Commit 8321e40

Browse files
committed
Fix test setting & Add instances to private fields
1 parent 552b654 commit 8321e40

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

Flow.Launcher.Test/Plugins/CalculatorTest.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ namespace Flow.Launcher.Test.Plugins
1212
public class CalculatorPluginTest
1313
{
1414
private readonly Main _plugin;
15+
private readonly Settings _settings = new()
16+
{
17+
DecimalSeparator = DecimalSeparator.UseSystemLocale,
18+
MaxDecimalPlaces = 10,
19+
ShowErrorMessage = false // Make sure we return the empty results when error occurs
20+
};
21+
private readonly Engine _engine = new(new Configuration
22+
{
23+
Scope = new Dictionary<string, object>
24+
{
25+
{ "e", Math.E }, // e is not contained in the default mages engine
26+
}
27+
});
1528

1629
public CalculatorPluginTest()
1730
{
@@ -20,21 +33,12 @@ public CalculatorPluginTest()
2033
var settingField = typeof(Main).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance);
2134
if (settingField == null)
2235
Assert.Fail("Could not find field '_settings' on Flow.Launcher.Plugin.Calculator.Main");
23-
settingField.SetValue(_plugin, new Settings
24-
{
25-
ShowErrorMessage = false // Make sure we return the empty results when error occurs
26-
});
36+
settingField.SetValue(_plugin, _settings);
2737

2838
var engineField = typeof(Main).GetField("MagesEngine", BindingFlags.NonPublic | BindingFlags.Static);
2939
if (engineField == null)
3040
Assert.Fail("Could not find static field 'MagesEngine' on Flow.Launcher.Plugin.Calculator.Main");
31-
engineField.SetValue(null, new Engine(new Configuration
32-
{
33-
Scope = new Dictionary<string, object>
34-
{
35-
{ "e", Math.E }, // e is not contained in the default mages engine
36-
}
37-
}));
41+
engineField.SetValue(null, _engine);
3842
}
3943

4044
// Basic operations

0 commit comments

Comments
 (0)