Skip to content

Commit 33e714f

Browse files
committed
fix(tests): clean NUnit 3->4 conversion from release/9.3 baseline
Re-checkout all 261 test files from origin/release/9.3 and run scripts/tests/convert_nunit.py with corrected comparison logic. This fixes swapped argument order in Greater/Less assertions that were introduced during the SDK migration rebase (43d1fd5). The previous conversion incorrectly produced: Assert.That(0, Is.GreaterThan(value)) // WRONG - always false Now correctly produces: Assert.That(value, Is.GreaterThan(0)) // CORRECT Also restores 3 test files that were unintentionally deleted during the SDK migration: - Lib/src/ScrChecks/ScrChecksTests/SentenceFinalPunctCapitalizationCheckUnitTest.cs - Src/Common/ViewsInterfaces/ViewsInterfacesTests/ExtraComInterfacesTests.cs - Src/FwCoreDlgs/FwCoreDlgsTests/FwWritingSystemSetupDlgTests.cs
1 parent f486c60 commit 33e714f

File tree

58 files changed

+4468
-6426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4468
-6426
lines changed

Lib/src/ScrChecks/ScrChecksTests/ChapterVerseTests.cs

Lines changed: 866 additions & 1638 deletions
Large diffs are not rendered by default.

Lib/src/ScrChecks/ScrChecksTests/RepeatedWordsCheckUnitTest.cs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
using System;
66
using System.Collections.Generic;
7-
using System.Diagnostics;
87
using NUnit.Framework;
9-
using SIL.FieldWorks.Common.FwUtils;
8+
using System.Diagnostics;
109
using SILUBS.ScriptureChecks;
10+
using SILUBS.SharedScrUtils;
1111

1212
namespace SILUBS.ScriptureChecks
1313
{
@@ -18,7 +18,9 @@ public class RepeatedWordsCheckUnitTest
1818
UnitTestChecksDataSource source = new UnitTestChecksDataSource();
1919

2020
[SetUp]
21-
public void RunBeforeEachTest() { }
21+
public void RunBeforeEachTest()
22+
{
23+
}
2224

2325
void Test(string[] result, string text)
2426
{
@@ -30,20 +32,13 @@ void Test(string[] result, string text, string desiredKey)
3032
source.Text = text;
3133

3234
RepeatedWordsCheck check = new RepeatedWordsCheck(source);
33-
List<TextTokenSubstring> tts = check.GetReferences(source.TextTokens(), desiredKey);
35+
List<TextTokenSubstring> tts =
36+
check.GetReferences(source.TextTokens(), desiredKey);
3437

35-
Assert.That(
36-
tts.Count,
37-
Is.EqualTo(result.GetUpperBound(0) + 1),
38-
"A different number of results was returned than what was expected."
39-
);
38+
Assert.That(tts.Count, Is.EqualTo(result.GetUpperBound(0)+1), "A different number of results was returned than what was expected.");
4039

4140
for (int i = 0; i <= result.GetUpperBound(0); ++i)
42-
Assert.That(
43-
tts[i].InventoryText,
44-
Is.EqualTo(result[i]),
45-
"Result number: " + i.ToString()
46-
);
41+
Assert.That(tts[i].InventoryText, Is.EqualTo(result[i]), "Result number: " + i.ToString());
4742
}
4843

4944
[Test]
@@ -68,21 +63,16 @@ public void DifferentCase()
6863
[Ignore("Text needs to be normalized to NFC (or maybe NFD) before check is run.")]
6964
public void DifferentNormalization()
7065
{
71-
Test(
72-
new string[] { "B\u00E3r", "B\u00E3r" },
73-
"\\p \\v 1 B\u00E3r Ba\u0303r and Ba\u0303r B\u00E3r "
74-
);
66+
Test(new string[] { "B\u00E3r", "B\u00E3r" },
67+
"\\p \\v 1 B\u00E3r Ba\u0303r and Ba\u0303r B\u00E3r ");
7568
}
7669

7770
[Test]
7871
[Ignore("Text needs to be normalized to NFC (or maybe NFD) before check is run.")]
7972
public void FindingDifferentNormalization()
8073
{
81-
Test(
82-
new string[] { "B\u00E3r", "B\u00E3r" },
83-
"\\p \\v 1 B\u00E3r Ba\u0303r and and Ba\u0303r B\u00E3r ",
84-
"B\u00E3r"
85-
);
74+
Test(new string[] { "B\u00E3r", "B\u00E3r" },
75+
"\\p \\v 1 B\u00E3r Ba\u0303r and and Ba\u0303r B\u00E3r ", "B\u00E3r");
8676
}
8777

8878
[Test]
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Copyright (c) 2015 SIL International
2+
// This software is licensed under the LGPL, version 2.1 or later
3+
// (http://www.gnu.org/licenses/lgpl-2.1.html)
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
using NUnit.Framework;
9+
using System.Diagnostics;
10+
using System.IO;
11+
using SILUBS.SharedScrUtils;
12+
13+
namespace SILUBS.ScriptureChecks
14+
{
15+
#if DEBUG
16+
[TestFixture]
17+
public class SentenceFinalPunctCapitalizationCheckUnitTest
18+
{
19+
UnitTestChecksDataSource source = new UnitTestChecksDataSource();
20+
21+
[SetUp]
22+
public void RunBeforeEachTest()
23+
{
24+
source.SetParameterValue("ValidPunctuation", "._ !_ ?_");
25+
}
26+
27+
void Test(string[] result, string text)
28+
{
29+
source.Text = text;
30+
31+
SentenceFinalPunctCapitalizationCheck check = new SentenceFinalPunctCapitalizationCheck(source);
32+
List<TextTokenSubstring> tts =
33+
check.GetReferences(source.TextTokens(), "");
34+
35+
Assert.That(tts.Count, Is.EqualTo(result.GetUpperBound(0)+1), "A different number of results was returned than what was expected.");
36+
37+
for (int i = 0; i <= result.GetUpperBound(0); ++i)
38+
Assert.That(tts[i].InventoryText, Is.EqualTo(result[i]), "Result number: " + i.ToString());
39+
}
40+
41+
[Test]
42+
public void UpperCase()
43+
{
44+
Test(new string[] { }, @"\p \v 1 Foo. Bar");
45+
}
46+
47+
[Test]
48+
public void LowerCase()
49+
{
50+
Test(new string[] { "." }, @"\p \v 1 Foo. bar");
51+
}
52+
53+
[Test]
54+
public void NoCaseNonRoman()
55+
{
56+
Test(new string[] { }, "\\p \\v 1 Foo. \u0E01");
57+
}
58+
59+
[Test]
60+
public void NoCasePUA()
61+
{
62+
Test(new string[] { }, "\\p \\v 1 Foo. \uEE00");
63+
}
64+
65+
[Test]
66+
public void TitleCase()
67+
{
68+
Test(new string[] { }, "\\p \\v 1 Foo. \u01C5");
69+
}
70+
71+
[Test]
72+
public void MultipleUpperCase()
73+
{
74+
Test(new string[] { }, @"\p \v 1 Foo. Bar! Baz");
75+
}
76+
77+
[Test]
78+
public void MultipleLowerCase()
79+
{
80+
Test(new string[] { ".", "!" }, @"\p \v 1 Foo. bar! baz");
81+
}
82+
83+
[Test]
84+
public void MultipleMixedCase()
85+
{
86+
Test(new string[] { "!" }, @"\p \v 1 Foo. Bar! baz");
87+
}
88+
89+
[Test]
90+
public void MultiplePunctUpperCase()
91+
{
92+
Test(new string[] { }, @"\p \v 1 Foo!? Bar");
93+
}
94+
95+
[Test]
96+
public void MultiplePunctLowerCase()
97+
{
98+
Test(new string[] { "!", "?" }, @"\p \v 1 Foo!? bar");
99+
}
100+
101+
[Test]
102+
public void Quotes()
103+
{
104+
Test(new string[] { "!" }, "\\p \\v 1 \u201CFoo!\u201D bar");
105+
}
106+
107+
[Test]
108+
public void Digits()
109+
{
110+
Test(new string[] { }, @"\p \v 1 Foo 1.2 bar");
111+
}
112+
113+
[Test]
114+
public void AbbreviationError()
115+
{
116+
Test(new string[] { "." }, @"\p \v 1 The E.U. headquarters.");
117+
}
118+
119+
[Test]
120+
public void AbbreviationOK()
121+
{
122+
source.SetParameterValue("Abbreviations", "E.U.");
123+
Test(new string[] { }, @"\p \v 1 The E.U. headquarters.");
124+
}
125+
}
126+
#endif
127+
}

Src/CacheLight/CacheLightTests/RealDataCacheTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public void AllMultiStringPropTest()
586586
SilDataAccess.SetMultiStringAlt(hvo, tag, 2, tss);
587587

588588
var tsms = SilDataAccess.get_MultiStringProp(hvo, tag);
589-
Assert.That(2, Is.EqualTo(tsms.StringCount));
589+
Assert.That(tsms.StringCount, Is.EqualTo(2));
590590
}
591591

592592
/// <summary>

Src/Common/Controls/DetailControls/DetailControlsTests/DataTreeTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void LabelAbbreviations()
178178
// are abbreviated by being truncated to 4 characters.
179179
Assert.That((m_dtree.Controls[0] as Slice).Label, Is.EqualTo("CitationForm"));
180180
string abbr1 = StringTable.Table.GetString((m_dtree.Controls[0] as Slice).Label, "LabelAbbreviations");
181-
Assert.That("*" + (m_dtree.Controls[0] as Slice).Label + "*", Is.EqualTo(abbr1)); // verify it's not in the table.
181+
Assert.That(abbr1, Is.EqualTo("*" + (m_dtree.Controls[0] as Slice).Label + "*")); // verify it's not in the table.
182182
Assert.That((m_dtree.Controls[0] as Slice).Abbreviation, Is.EqualTo("Cita")); // verify truncation took place.
183183
// 2) Test that a label in "LabelAbbreviations" defaults to its string table entry.
184184
Assert.That((m_dtree.Controls[1] as Slice).Label, Is.EqualTo("Citation Form"));
@@ -187,7 +187,7 @@ public void LabelAbbreviations()
187187
Assert.That((m_dtree.Controls[1] as Slice).Abbreviation, Is.EqualTo(abbr2)); // should be identical
188188
// 3) Test that a label with an "abbr" attribute overrides default abbreviation.
189189
Assert.That((m_dtree.Controls[2] as Slice).Label, Is.EqualTo("Citation Form"));
190-
Assert.That("!?", Is.EqualTo((m_dtree.Controls[2] as Slice).Abbreviation));
190+
Assert.That((m_dtree.Controls[2] as Slice).Abbreviation, Is.EqualTo("!?"));
191191
Assert.That(abbr2 == (m_dtree.Controls[2] as Slice).Abbreviation, Is.False);
192192
}
193193

0 commit comments

Comments
 (0)