Skip to content

Commit

Permalink
Added a Timeout property.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgnsm committed May 10, 2022
1 parent 00790d9 commit 0f0f4aa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Source/Millistream.Streaming/MDF_OPTION.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal enum MDF_OPTION
MDF_OPT_CRYPT_DIGESTS,
MDF_OPT_CRYPT_CIPHERS,
MDF_OPT_CRYPT_DIGEST,
MDF_OPT_CRYPT_CIPHER
MDF_OPT_CRYPT_CIPHER,
MDF_OPT_TIMEOUT
};
}
7 changes: 7 additions & 0 deletions Source/Millistream.Streaming/MarketDataFeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ public string Ciphers
/// <exception cref="InvalidOperationException">The native value of the <see cref="MDF_OPTION.MDF_OPT_CRYPT_CIPHER"/> option cannot be fetched.</exception>
/// <exception cref="ObjectDisposedException">The <see cref="MarketDataFeed{TCallbackData,TStatusCallbackData}"/> instance has been disposed.</exception>
public string Cipher => GetStringProperty(MDF_OPTION.MDF_OPT_CRYPT_CIPHER);

/// <summary>
/// Returns the number of seconds to wait before having to call <see cref="Consume(int)"/>.
/// </summary>
/// <exception cref="InvalidOperationException">The native value of the <see cref="MDF_OPTION.MDF_OPT_TIMEOUT"/> option cannot be fetched.</exception>
/// <exception cref="ObjectDisposedException">The <see cref="MarketDataFeed{TCallbackData,TStatusCallbackData}"/> instance has been disposed.</exception>
public int Timeout => GetInt32Property(MDF_OPTION.MDF_OPT_TIMEOUT);
#endregion

#region Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public void GetAndSetPropertiesTest()

_ = mdf.TimeDifferenceNs;

//Timeout
_ = mdf.Timeout;

//Allocations
long allocatedBytes = GetTotalAllocatedBytes();
_ = mdf.FileDescriptor;
Expand Down Expand Up @@ -145,6 +148,8 @@ public void GetAndSetPropertiesTest()

mdf.BindAddress = "abc";

_ = mdf.Timeout;

Assert.AreEqual(allocatedBytes, GetTotalAllocatedBytes());
}

Expand Down
8 changes: 8 additions & 0 deletions Tests/Millistream.Streaming.UnitTests/MarketDataFeedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ public void GetMessageDigestTest() =>
public void GetCipherTest() =>
GetStringProperty(MDF_OPTION.MDF_OPT_CRYPT_CIPHER, mdf => mdf.Cipher);

[TestMethod]
public void GetTimeoutTest() =>
GetInt32Property(MDF_OPTION.MDF_OPT_TIMEOUT, mdf => mdf.Timeout);

[TestMethod]
public void GetAndSetDataCallbackTest()
{
Expand Down Expand Up @@ -682,6 +686,10 @@ public void SendTest()
[ExpectedException(typeof(ObjectDisposedException))]
public void CannotGetCipherAfterDisposeTest() => _ = GetDisposedMdf().Cipher;

[TestMethod]
[ExpectedException(typeof(ObjectDisposedException))]
public void CannotGetTimeoutAfterDisposeTest() => _ = GetDisposedMdf().Timeout;

[TestMethod]
[ExpectedException(typeof(ObjectDisposedException))]
public void CannotGetDataCallbackfterDisposeTest() => _ = GetDisposedMdf().DataCallback;
Expand Down

0 comments on commit 0f0f4aa

Please sign in to comment.