Skip to content

Commit c055302

Browse files
authored
Merge pull request #892 from gbirchmeier/ut-cleanup
cleanup/nullable-ize UnitTests project
2 parents 2d544b5 + bc570a2 commit c055302

28 files changed

+1127
-1149
lines changed

QuickFIXn/AcceptorSocketDescriptor.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Net;
34
using QuickFix.Logger;
@@ -14,13 +15,20 @@ internal class AcceptorSocketDescriptor
1415
public AcceptorSocketDescriptor(
1516
IPEndPoint socketEndPoint,
1617
SocketSettings socketSettings,
17-
SettingsDictionary sessionDict,
1818
NonSessionLog nonSessionLog)
1919
{
2020
Address = socketEndPoint;
21-
SocketReactor = new ThreadedSocketReactor(Address, socketSettings, sessionDict, this, nonSessionLog);
21+
SocketReactor = new ThreadedSocketReactor(Address, socketSettings, this, nonSessionLog);
2222
}
2323

24+
[Obsolete("Param 'sessionDict' is unused. Use the alt constructor without it.")]
25+
public AcceptorSocketDescriptor(
26+
IPEndPoint socketEndPoint,
27+
SocketSettings socketSettings,
28+
SettingsDictionary sessionDict,
29+
NonSessionLog nonSessionLog) : this(socketEndPoint, socketSettings, nonSessionLog)
30+
{ }
31+
2432
internal void AcceptSession(Session session)
2533
{
2634
lock (_acceptedSessions)

QuickFIXn/Fields/Converters/AsciiConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ public static class AsciiValidator
1010
public const int ASCII_NINE = 57;
1111
public const int ASCII_MINUS = 45;
1212

13-
/// <summary>
1413
/// TODO can we use NumberFormatInfo or NumberStyles to avoid this bit of ASCII hackery?
15-
/// Validates that a string looks like number (for use before conversion to an int, ulong, etc.).
14+
/// <summary>
15+
/// Validates that a string looks like a number (for use before conversion to an int, ulong, etc.).
1616
/// </summary>
1717
/// <param name="i"></param>
1818
/// <returns></returns>
1919
public static void Validate(string i)
2020
{
21-
if ((null == i) || (i.Length < 1))
21+
if (i is null || i.Length < 1)
2222
throw new FieldConvertError("The argument string cannot be null or empty");
2323
int asciiValOfFirstChar = System.Convert.ToInt32(i[0]);
24-
if ((asciiValOfFirstChar < ASCII_ZERO) || (asciiValOfFirstChar > ASCII_NINE))
24+
if (asciiValOfFirstChar < ASCII_ZERO || asciiValOfFirstChar > ASCII_NINE)
2525
if (asciiValOfFirstChar != ASCII_MINUS)
2626
throw new FieldConvertError("Could not convert string to int (" + i + "): The first character must be a digit or a minus sign");
2727
}

QuickFIXn/IApplicationExt.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ namespace QuickFix
77
/// and facilitates early interception of such messages. 'Early', in this context,
88
/// means after structure, length and checksum have been validated, but before any
99
/// further validation has been performed.
10+
///
1011
/// This interface will not normally be required, and it should be used only with caution:
11-
/// it allows modfications to be made to irregular inbound messages that would otherwise
12+
/// it allows modifications to be made to irregular inbound messages that would otherwise
1213
/// fail validation against the Fix dictionary, an provides an alternative to dictionary
1314
/// customisation as a means of dealing with such messages.
1415
/// </summary>
1516
public interface IApplicationExt : IApplication
1617
{
1718
/// <summary>
18-
/// This callback provides early notification of when an administrative or application message is sent from a counterparty to your FIX engine.
19-
/// This can be useful for doing pre-processing of an inbound message after its structure, checksum and length have been validated, but before
20-
/// any further validation has been performed on it.
19+
/// This callback provides early notification of when an administrative or application
20+
/// message is sent from a counterparty to your FIX engine.
21+
/// This can be useful for doing pre-processing of an inbound message after its structure,
22+
/// checksum and length have been validated, but before
23+
/// any further validation has been performed on it.
2124
/// </summary>
2225
/// <param name="message">received message</param>
23-
/// <param name="sessionID">session on which message received</param>
24-
void FromEarlyIntercept(Message message, SessionID sessionID);
26+
/// <param name="sessionId">session on which message received</param>
27+
void FromEarlyIntercept(Message message, SessionID sessionId);
2528
}
2629
}

QuickFIXn/ThreadedSocketAcceptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private AcceptorSocketDescriptor GetAcceptorSocketDescriptor(SettingsDictionary
9494

9595
if (!_socketDescriptorForAddress.TryGetValue(socketEndPoint, out var descriptor))
9696
{
97-
descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, dict, _nonSessionLog);
97+
descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, _nonSessionLog);
9898
_socketDescriptorForAddress[socketEndPoint] = descriptor;
9999
}
100100

QuickFIXn/ThreadedSocketReactor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public State ReactorState
3636
internal ThreadedSocketReactor(
3737
IPEndPoint serverSocketEndPoint,
3838
SocketSettings socketSettings,
39-
SettingsDictionary sessionDict,
4039
AcceptorSocketDescriptor? acceptorSocketDescriptor,
4140
NonSessionLog nonSessionLog)
4241
{

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ What's New
4040
* deprecate <Foo>Field.Obj (renamed to Value)
4141
* deprecate <Foo>Field.getValue/setValue (just use Value getter/setter)
4242
* #889 - nullable-ize Examples and fix deprecations (gbirchmeier)
43+
* #892 - nullable-ize UnitTests project (gbirchmeier)
44+
* also deprecate a AcceptorSocketDescriptor ctor due to unused param
4345

4446
### v1.12.0
4547

UnitTests/DataDictionaryTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ private static XmlNode MakeNode(string xmlString)
379379
if (xmlString.StartsWith('<'))
380380
{
381381
doc.LoadXml(xmlString);
382-
return doc.DocumentElement;
382+
return doc.DocumentElement!;
383383
}
384384
return doc.CreateTextNode(xmlString);
385385
}
@@ -392,18 +392,18 @@ public void VerifyChildNodeAndReturnNameAtt() {
392392
MakeNode("<sometag name='qty'/>"), parentNode));
393393

394394
DictionaryParseException dpx = Assert.Throws<DictionaryParseException>(
395-
delegate { DataDictionary.VerifyChildNodeAndReturnNameAtt(MakeNode("foo"), parentNode); });
396-
Assert.AreEqual("Malformed data dictionary: Found text-only node containing 'foo'", dpx!.Message);
395+
delegate { DataDictionary.VerifyChildNodeAndReturnNameAtt(MakeNode("foo"), parentNode); })!;
396+
Assert.AreEqual("Malformed data dictionary: Found text-only node containing 'foo'", dpx.Message);
397397

398398
dpx = Assert.Throws<DictionaryParseException>(
399-
delegate { DataDictionary.VerifyChildNodeAndReturnNameAtt(MakeNode("<field>qty</field>"), parentNode); });
400-
Assert.AreEqual("Malformed data dictionary: Found 'field' node without 'name' within parent 'parentnode/Daddy'", dpx!.Message);
399+
delegate { DataDictionary.VerifyChildNodeAndReturnNameAtt(MakeNode("<field>qty</field>"), parentNode); })!;
400+
Assert.AreEqual("Malformed data dictionary: Found 'field' node without 'name' within parent 'parentnode/Daddy'", dpx.Message);
401401

402402
// alt error message, where parent has no name
403403
parentNode = MakeNode("<parentnode/>");
404404
dpx = Assert.Throws<DictionaryParseException>(
405-
delegate { DataDictionary.VerifyChildNodeAndReturnNameAtt(MakeNode("<field>qty</field>"), parentNode); });
406-
Assert.AreEqual("Malformed data dictionary: Found 'field' node without 'name' within parent 'parentnode/parentnode'", dpx!.Message);
405+
delegate { DataDictionary.VerifyChildNodeAndReturnNameAtt(MakeNode("<field>qty</field>"), parentNode); })!;
406+
Assert.AreEqual("Malformed data dictionary: Found 'field' node without 'name' within parent 'parentnode/parentnode'", dpx.Message);
407407
}
408408
}
409409
}

UnitTests/DataDictionary_ValidateTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#nullable enable
2-
3-
using System;
41
using NUnit.Framework;
52
using QuickFix;
63
using QuickFix.DataDictionary;

UnitTests/Fields/Converters/DecimalConverterTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@ public class DecimalConverterTests {
1111
[Test]
1212
public void Convert()
1313
{
14-
Assert.That(DecimalConverter.Convert(new Decimal(4.23322)), Is.EqualTo("4.23322"));
15-
Assert.That(DecimalConverter.Convert(new Decimal(-4.23322)), Is.EqualTo("-4.23322"));
14+
Assert.That(DecimalConverter.Convert(4.23322m), Is.EqualTo("4.23322"));
15+
Assert.That(DecimalConverter.Convert(-4.23322m), Is.EqualTo("-4.23322"));
1616
Assert.That(DecimalConverter.Convert("4332.33"), Is.EqualTo(new Decimal(4332.33)));
1717
Assert.That(DecimalConverter.Convert("3.000000000021874E-4"), Is.EqualTo(0.0003000000000021874M));
1818
Assert.Throws(typeof(FieldConvertError), delegate { DecimalConverter.Convert("2.32a34"); });
1919
Assert.Throws(typeof(FieldConvertError), delegate { DecimalConverter.Convert("+1.2"); });
2020
Assert.Throws(typeof(FieldConvertError), delegate { DecimalConverter.Convert("(1.2)"); });
2121
Assert.Throws(typeof(FieldConvertError), delegate { DecimalConverter.Convert(""); });
22-
Assert.Throws(typeof(FieldConvertError), delegate { DecimalConverter.Convert(null); });
22+
Assert.Throws(typeof(FieldConvertError), delegate { DecimalConverter.Convert(null!); });
2323

2424
// check for a different culture than en-XX
25-
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo( "tr-TR" );
26-
Assert.That( DecimalConverter.Convert( "4332.33" ), Is.EqualTo( new Decimal( 4332.33 ) ) );
27-
Assert.That( DecimalConverter.Convert( "-2.33" ), Is.EqualTo( new Decimal( -2.33 ) ) );
28-
Assert.That( DecimalConverter.Convert( new Decimal( 4.23322 ) ), Is.EqualTo( "4.23322" ) );
29-
Assert.That( DecimalConverter.Convert( new Decimal( -4.23322 ) ), Is.EqualTo( "-4.23322" ) );
25+
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("tr-TR");
26+
Assert.That(DecimalConverter.Convert("4332.33"), Is.EqualTo(4332.33m));
27+
Assert.That(DecimalConverter.Convert("-2.33"), Is.EqualTo(-2.33m));
28+
Assert.That(DecimalConverter.Convert(4.23322m), Is.EqualTo("4.23322"));
29+
Assert.That(DecimalConverter.Convert(-4.23322m), Is.EqualTo("-4.23322"));
3030
}
3131

3232
[Test]
3333
public void Convert_WithoutLeadingTrailingZeros()
3434
{
35-
Assert.That(DecimalConverter.Convert("23."), Is.EqualTo(new Decimal(23)));
36-
Assert.That(DecimalConverter.Convert(".23"), Is.EqualTo(new Decimal(0.23)));
37-
Assert.That(DecimalConverter.Convert("-.23"), Is.EqualTo(new Decimal(-0.23)));
35+
Assert.That(DecimalConverter.Convert("23."), Is.EqualTo(23m));
36+
Assert.That(DecimalConverter.Convert(".23"), Is.EqualTo(0.23m));
37+
Assert.That(DecimalConverter.Convert("-.23"), Is.EqualTo(-0.23m));
3838
}
3939
}

UnitTests/Fields/Converters/IntConverterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ public void Convert()
1919
Assert.Throws(typeof(FieldConvertError), delegate { IntConverter.Convert("AB"); });
2020
Assert.Throws(typeof(FieldConvertError), delegate { IntConverter.Convert("2.3234"); });
2121
Assert.Throws(typeof(FieldConvertError), delegate { IntConverter.Convert(""); });
22-
Assert.Throws(typeof(FieldConvertError), delegate { IntConverter.Convert(null); });
22+
Assert.Throws(typeof(FieldConvertError), delegate { IntConverter.Convert(null!); });
2323
}
2424
}

0 commit comments

Comments
 (0)