Skip to content

Commit 971e85d

Browse files
committed
fix some test issues
1 parent 91c4f72 commit 971e85d

File tree

17 files changed

+104
-288
lines changed

17 files changed

+104
-288
lines changed

src/Spring/Spring.Services/EnterpriseServices/EnterpriseServicesExporter.cs

-8
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818

1919
#endregion
2020

21-
#if !MONO
22-
23-
#region Imports
24-
2521
using System;
2622
using System.Collections;
2723
using System.Diagnostics;
@@ -33,8 +29,6 @@
3329
using Spring.Objects.Factory;
3430
using Spring.Util;
3531

36-
#endregion
37-
3832
namespace Spring.EnterpriseServices
3933
{
4034
/// <summary>
@@ -613,5 +607,3 @@ private static Type DefineDelegate(ModuleBuilder module)
613607
#endregion
614608
}
615609
}
616-
617-
#endif // (!MONO)

src/Spring/Spring.Services/EnterpriseServices/ExeConfigurationSystem.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
namespace Spring.EnterpriseServices
2222
{
23-
#if !MONO
2423
using System;
2524
using System.Configuration;
2625
using System.Reflection;
@@ -152,5 +151,4 @@ public object GetSection(string sectionName)
152151
return result;
153152
}
154153
}
155-
#endif
156-
}
154+
}

src/Spring/Spring.Services/EnterpriseServices/ServicedComponentExporter.cs

-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
#endregion
2020

21-
#if !MONO
22-
2321
#region Imports
2422

2523
using System;
@@ -352,5 +350,3 @@ public override void PushTarget( ILGenerator il )
352350
#endregion
353351
}
354352
}
355-
356-
#endif // !MONO

src/Spring/Spring.Services/EnterpriseServices/ServicedComponentHelper.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region License
22

33
/*
4-
* Copyright © 2002-2011 the original author or authors.
4+
* Copyright 2002-2011 the original author or authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -18,8 +18,6 @@
1818

1919
#endregion
2020

21-
#if !MONO
22-
2321
#region Imports
2422

2523
using System;
@@ -170,5 +168,3 @@ public static object GetObject(ServicedComponent sender, string targetName)
170168
}
171169
}
172170
}
173-
174-
#endif

test/Spring/Spring.Core.Tests/Globalization/AbstractLocalizerTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void TestInvariantCulture()
6767
Assert.AreEqual("Croatia", tesla.PlaceOfBirth.Country);
6868
Assert.AreEqual("Smiljan", tesla.PlaceOfBirth.City);
6969
}
70-
#if !MONO
70+
7171
[Test]
7272
public void TestSerbianLatin()
7373
{
@@ -89,7 +89,7 @@ public void TestSerbianCyrillic()
8989
Assert.AreEqual("Хрватска", tesla.PlaceOfBirth.Country);
9090
Assert.AreEqual("Смиљан", tesla.PlaceOfBirth.City);
9191
}
92-
#endif
92+
9393
[Test]
9494
public void NullReferenceHandling()
9595
{

test/Spring/Spring.Core.Tests/Globalization/CultureInfoUtils.cs

+2-59
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818

1919
#endregion
2020

21-
using System;
2221
using System.Globalization;
23-
using Microsoft.Win32;
24-
25-
#pragma warning disable CA1416 // is only supported on windows
2622

2723
namespace Spring.Globalization
2824
{
@@ -64,61 +60,8 @@ static CultureInfoUtils()
6460
}
6561
}
6662

67-
public static string SerbianCyrillicCultureName
68-
{
69-
get { return srCyrl; }
70-
}
71-
72-
public static string SerbianLatinCultureName
73-
{
74-
get { return srLatn; }
75-
}
76-
77-
public static bool OperatingSystemIsAfterWindows7
78-
{
79-
get { return Environment.OSVersion.Version.Major >= 6; }
80-
}
81-
82-
public static bool OperatingSystemIsAfterWindows7AndBeforeWindows10Build10586
83-
{
84-
get { return OperatingSystemIsAfterWindows7 && !OperatingSystemIsAtLeastWindows10Build10586; }
85-
}
86-
87-
public static bool OperatingSystemIsAtLeastWindows10Build10586
88-
{
89-
get
90-
{
91-
try
92-
{
93-
var registryBuildNumberString = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuildNumber", string.Empty) as string;
94-
95-
//if null or empty, we coudn't find the value or it couldn't be cast to a string
96-
if (!string.IsNullOrEmpty(registryBuildNumberString))
97-
{
98-
int buildNumber;
63+
public static string SerbianCyrillicCultureName => srCyrl;
9964

100-
//if we can convert the value to an int...
101-
if (int.TryParse(registryBuildNumberString, out buildNumber))
102-
{
103-
//do the comparison
104-
return buildNumber >= 10586;
105-
}
106-
}
107-
}
108-
catch (Exception)
109-
{
110-
//if anythign at all goes wrong, presume we're not on Windows 10 Build 10586 or later
111-
return false;
112-
}
113-
114-
//if we get this far, we can't tell WTF is going on, so just return FALSE
115-
return false;
116-
}
117-
}
118-
119-
public static bool ClrIsVersion4OrLater
120-
{
121-
get { return Environment.Version.Major >= 4; }
122-
}
65+
public static string SerbianLatinCultureName => srLatn;
12366
}
12467
}

test/Spring/Spring.Core.Tests/Globalization/Formatters/CurrencyFormatterTests.cs

+45-120
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void FormatNonNumber()
5151
CurrencyFormatter fmt = new CurrencyFormatter();
5252
Assert.Throws<ArgumentException>(() => fmt.Format("not a number"));
5353
}
54-
#if !MONO
54+
5555
[Test]
5656
[Platform("Win")]
5757
public void FormatUsingDefaults()
@@ -64,47 +64,24 @@ public void FormatUsingDefaults()
6464

6565
fmt = new CurrencyFormatter(CultureInfoUtils.SerbianLatinCultureName);
6666

67-
if (CultureInfoUtils.OperatingSystemIsAfterWindows7AndBeforeWindows10Build10586 && CultureInfoUtils.ClrIsVersion4OrLater)
68-
{
69-
Assert.AreEqual("1.234,00 din.", fmt.Format(1234));
70-
Assert.AreEqual("1.234,56 din.", fmt.Format(1234.56));
71-
Assert.AreEqual("-1.234,00 din.", fmt.Format(-1234));
72-
Assert.AreEqual("-1.234,56 din.", fmt.Format(-1234.56));
73-
}
74-
75-
else if (CultureInfoUtils.OperatingSystemIsAtLeastWindows10Build10586 && CultureInfoUtils.ClrIsVersion4OrLater)
76-
{
77-
Assert.AreEqual("1.234 RSD", fmt.Format(1234));
78-
Assert.AreEqual("1.235 RSD", fmt.Format(1234.56));
79-
Assert.AreEqual("-1.234 RSD", fmt.Format(-1234));
80-
Assert.AreEqual("-1.235 RSD", fmt.Format(-1234.56));
81-
}
82-
83-
else
84-
{
85-
Assert.AreEqual("1.234,00 Din.", fmt.Format(1234));
86-
Assert.AreEqual("1.234,56 Din.", fmt.Format(1234.56));
87-
Assert.AreEqual("-1.234,00 Din.", fmt.Format(-1234));
88-
Assert.AreEqual("-1.234,56 Din.", fmt.Format(-1234.56));
89-
}
67+
Assert.AreEqual("1.234 RSD", fmt.Format(1234));
68+
Assert.AreEqual("1.235 RSD", fmt.Format(1234.56));
69+
Assert.AreEqual("-1.234 RSD", fmt.Format(-1234));
70+
Assert.AreEqual("-1.235 RSD", fmt.Format(-1234.56));
9071

9172
fmt = new CurrencyFormatter(CultureInfoUtils.SerbianCyrillicCultureName);
9273

93-
if (CultureInfoUtils.OperatingSystemIsAfterWindows7 && CultureInfoUtils.ClrIsVersion4OrLater)
94-
{
95-
Assert.AreEqual("1.234,00 дин.", fmt.Format(1234));
96-
Assert.AreEqual("1.234,56 дин.", fmt.Format(1234.56));
97-
Assert.AreEqual("-1.234,00 дин.", fmt.Format(-1234));
98-
Assert.AreEqual("-1.234,56 дин.", fmt.Format(-1234.56));
99-
}
100-
else
101-
{
102-
Assert.AreEqual("1.234,00 Дин.", fmt.Format(1234));
103-
Assert.AreEqual("1.234,56 Дин.", fmt.Format(1234.56));
104-
Assert.AreEqual("-1.234,00 Дин.", fmt.Format(-1234));
105-
Assert.AreEqual("-1.234,56 Дин.", fmt.Format(-1234.56));
106-
}
107-
74+
#if NETFRAMEWORK
75+
Assert.AreEqual("1.234,00 дин.", fmt.Format(1234));
76+
Assert.AreEqual("1.234,56 дин.", fmt.Format(1234.56));
77+
Assert.AreEqual("-1.234,00 дин.", fmt.Format(-1234));
78+
Assert.AreEqual("-1.234,56 дин.", fmt.Format(-1234.56));
79+
#else
80+
Assert.AreEqual("1.234 RSD", fmt.Format(1234));
81+
Assert.AreEqual("1.235 RSD", fmt.Format(1234.56));
82+
Assert.AreEqual("-1.234 RSD", fmt.Format(-1234));
83+
Assert.AreEqual("-1.235 RSD", fmt.Format(-1234.56));
84+
#endif
10885
}
10986

11087
[Test]
@@ -119,45 +96,17 @@ public void ParseUsingDefaults()
11996

12097
fmt = new CurrencyFormatter(CultureInfoUtils.SerbianLatinCultureName);
12198

122-
if (CultureInfoUtils.OperatingSystemIsAfterWindows7AndBeforeWindows10Build10586 && CultureInfoUtils.ClrIsVersion4OrLater)
123-
{
124-
Assert.AreEqual(1234, fmt.Parse("1.234,00 din."));
125-
Assert.AreEqual(1234.56, fmt.Parse("1.234,56 din."));
126-
Assert.AreEqual(-1234, fmt.Parse("-1.234,00 din."));
127-
Assert.AreEqual(-1234.56, fmt.Parse("-1.234,56 din."));
128-
}
129-
130-
else if (CultureInfoUtils.OperatingSystemIsAtLeastWindows10Build10586 && CultureInfoUtils.ClrIsVersion4OrLater)
131-
{
132-
Assert.AreEqual(1234, fmt.Parse("1.234 RSD"));
133-
Assert.AreEqual(-1234, fmt.Parse("-1.234 RSD"));
134-
}
135-
136-
else
137-
{
138-
Assert.AreEqual(1234, fmt.Parse("1.234,00 Din."));
139-
Assert.AreEqual(1234.56, fmt.Parse("1.234,56 Din."));
140-
Assert.AreEqual(-1234, fmt.Parse("-1.234,00 Din."));
141-
Assert.AreEqual(-1234.56, fmt.Parse("-1.234,56 Din."));
142-
}
99+
Assert.AreEqual(1234, fmt.Parse("1.234 RSD"));
100+
Assert.AreEqual(-1234, fmt.Parse("-1.234 RSD"));
143101

144102
fmt = new CurrencyFormatter(CultureInfoUtils.SerbianCyrillicCultureName);
145103

146-
if (CultureInfoUtils.OperatingSystemIsAfterWindows7 && CultureInfoUtils.ClrIsVersion4OrLater)
147-
{
148-
Assert.AreEqual(1234, fmt.Parse("1.234,00 дин."));
149-
Assert.AreEqual(1234.56, fmt.Parse("1.234,56 дин."));
150-
Assert.AreEqual(-1234, fmt.Parse("-1.234,00 дин."));
151-
Assert.AreEqual(-1234.56, fmt.Parse("-1.234,56 дин."));
152-
}
153-
else
154-
{
155-
Assert.AreEqual(1234, fmt.Parse("1.234,00 Дин."));
156-
Assert.AreEqual(1234.56, fmt.Parse("1.234,56 Дин."));
157-
Assert.AreEqual(-1234, fmt.Parse("-1.234,00 Дин."));
158-
Assert.AreEqual(-1234.56, fmt.Parse("-1.234,56 Дин."));
159-
}
160-
104+
#if NETFRAMEWORK
105+
Assert.AreEqual(1234, fmt.Parse("1.234,00 дин."));
106+
Assert.AreEqual(1234.56, fmt.Parse("1.234,56 дин."));
107+
Assert.AreEqual(-1234, fmt.Parse("-1.234,00 дин."));
108+
Assert.AreEqual(-1234.56, fmt.Parse("-1.234,56 дин."));
109+
#endif
161110
}
162111

163112
[Test]
@@ -176,40 +125,26 @@ public void FormatUsingCustomSettings()
176125
fmt.PositivePattern = 1;
177126
fmt.CurrencySymbol = "din";
178127

179-
if (CultureInfoUtils.OperatingSystemIsAtLeastWindows10Build10586 && CultureInfoUtils.ClrIsVersion4OrLater)
180-
{
181-
Assert.AreEqual("1.234din", fmt.Format(1234));
182-
Assert.AreEqual("1.235din", fmt.Format(1234.56));
183-
Assert.AreEqual("-1.234 din", fmt.Format(-1234));
184-
Assert.AreEqual("-1.235 din", fmt.Format(-1234.56));
185-
}
186-
else
187-
{
188-
Assert.AreEqual("1.234,00din", fmt.Format(1234));
189-
Assert.AreEqual("1.234,56din", fmt.Format(1234.56));
190-
Assert.AreEqual("-1.234,00 din", fmt.Format(-1234));
191-
Assert.AreEqual("-1.234,56 din", fmt.Format(-1234.56));
192-
}
128+
Assert.AreEqual("1.234din", fmt.Format(1234));
129+
Assert.AreEqual("1.235din", fmt.Format(1234.56));
130+
Assert.AreEqual("-1.234 din", fmt.Format(-1234));
131+
Assert.AreEqual("-1.235 din", fmt.Format(-1234.56));
193132

194133
fmt = new CurrencyFormatter(CultureInfoUtils.SerbianCyrillicCultureName);
195134
fmt.GroupSizes = new int[] { 1, 2 };
196135
fmt.GroupSeparator = "'";
197136

198-
if (CultureInfoUtils.OperatingSystemIsAfterWindows7 && CultureInfoUtils.ClrIsVersion4OrLater)
199-
{
200-
Assert.AreEqual("1'23'4,00 дин.", fmt.Format(1234));
201-
Assert.AreEqual("1'23'4,56 дин.", fmt.Format(1234.56));
202-
Assert.AreEqual("-1'23'4,00 дин.", fmt.Format(-1234));
203-
Assert.AreEqual("-1'23'4,56 дин.", fmt.Format(-1234.56));
204-
}
205-
206-
else
207-
{
208-
Assert.AreEqual("1'23'4,00 Дин.", fmt.Format(1234));
209-
Assert.AreEqual("1'23'4,56 Дин.", fmt.Format(1234.56));
210-
Assert.AreEqual("-1'23'4,00 Дин.", fmt.Format(-1234));
211-
Assert.AreEqual("-1'23'4,56 Дин.", fmt.Format(-1234.56));
212-
}
137+
#if NETFRAMEWORK
138+
Assert.AreEqual("1'23'4,00 дин.", fmt.Format(1234));
139+
Assert.AreEqual("1'23'4,56 дин.", fmt.Format(1234.56));
140+
Assert.AreEqual("-1'23'4,00 дин.", fmt.Format(-1234));
141+
Assert.AreEqual("-1'23'4,56 дин.", fmt.Format(-1234.56));
142+
#else
143+
Assert.AreEqual("1'23'4 RSD", fmt.Format(1234));
144+
Assert.AreEqual("1'23'5 RSD", fmt.Format(1234.56));
145+
Assert.AreEqual("-1'23'4 RSD", fmt.Format(-1234));
146+
Assert.AreEqual("-1'23'5 RSD", fmt.Format(-1234.56));
147+
#endif
213148
}
214149

215150
[Test]
@@ -236,22 +171,12 @@ public void ParseUsingCustomSettings()
236171
fmt.GroupSizes = new int[] { 1, 2 };
237172
fmt.GroupSeparator = "'";
238173

239-
if (CultureInfoUtils.OperatingSystemIsAfterWindows7 && CultureInfoUtils.ClrIsVersion4OrLater)
240-
{
241-
Assert.AreEqual(1234, fmt.Parse("1'23'4,00 дин."));
242-
Assert.AreEqual(1234.56, fmt.Parse("1'23'4,56 дин."));
243-
Assert.AreEqual(-1234, fmt.Parse("-1'23'4,00 дин."));
244-
Assert.AreEqual(-1234.56, fmt.Parse("-1'23'4,56 дин."));
245-
}
246-
else
247-
{
248-
Assert.AreEqual(1234, fmt.Parse("1'23'4,00 Дин."));
249-
Assert.AreEqual(1234.56, fmt.Parse("1'23'4,56 Дин."));
250-
Assert.AreEqual(-1234, fmt.Parse("-1'23'4,00 Дин."));
251-
Assert.AreEqual(-1234.56, fmt.Parse("-1'23'4,56 Дин."));
252-
}
253-
254-
}
174+
#if NETFRAMEWORK
175+
Assert.AreEqual(1234, fmt.Parse("1'23'4,00 дин."));
176+
Assert.AreEqual(1234.56, fmt.Parse("1'23'4,56 дин."));
177+
Assert.AreEqual(-1234, fmt.Parse("-1'23'4,00 дин."));
178+
Assert.AreEqual(-1234.56, fmt.Parse("-1'23'4,56 дин."));
255179
#endif
180+
}
256181
}
257182
}

0 commit comments

Comments
 (0)