mirror of
https://github.com/StockSharp/StockSharp.git
synced 2026-12-06 01:22:11 +00:00
The wire both the server and the connector speak was declared in a server module, so a client had to compile against a server assembly to know its own record layout. The subscribe needed no message of its own: a DataType is a message type plus an argument, so an indicator is which one, on which series. That asks the argument to be a value - DataType caches its hash and compares by Arg.Equals - so the specification is one now, and two clients asking for the same indicator get the same data type and share one computation. Numbers are stored one way, because 20 written in code is an int and 20 off a JSON frame is a long. The warm-up needed none either: a subscription already says where history ends, and warm-up and live values are the same values. Only the names of the outputs survive it, in a message sent once ahead of them - values carry several series positionally and a client cannot work out which is which. The wire keeps its indicatorSubscribe command.
48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
namespace StockSharp.Tests;
|
|
|
|
/// <summary>
|
|
/// Independence guarantees of mutable indicator message payloads.
|
|
/// </summary>
|
|
[TestClass]
|
|
public class IndicatorMessageCloneTests : BaseTestClass
|
|
{
|
|
[TestMethod]
|
|
public void PointClone_HasIndependentPointAndValues()
|
|
{
|
|
var original = new IndicatorMessage
|
|
{
|
|
Point = new IndicatorPoint
|
|
{
|
|
Time = new DateTime(2026, 8, 1, 10, 0, 0, DateTimeKind.Utc),
|
|
Values = [1m, 2m],
|
|
},
|
|
};
|
|
|
|
var clone = (IndicatorMessage)original.Clone();
|
|
clone.Point.Time = clone.Point.Time.AddMinutes(1);
|
|
clone.Point.Values[0] = 10m;
|
|
|
|
AreNotSame(original.Point, clone.Point);
|
|
AreNotSame(original.Point.Values, clone.Point.Values);
|
|
AreEqual(new DateTime(2026, 8, 1, 10, 0, 0, DateTimeKind.Utc), original.Point.Time);
|
|
AreEqual(1m, original.Point.Values[0]);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void InfoClone_HasIndependentOutputNames()
|
|
{
|
|
var original = new IndicatorInfoMessage
|
|
{
|
|
OriginalTransactionId = 7,
|
|
OutputNames = ["upper", "middle", "lower"],
|
|
};
|
|
|
|
var clone = (IndicatorInfoMessage)original.Clone();
|
|
clone.OutputNames[0] = "value";
|
|
|
|
AreNotSame(original.OutputNames, clone.OutputNames);
|
|
AreEqual("upper", original.OutputNames[0]);
|
|
AreEqual(7L, clone.OriginalTransactionId);
|
|
}
|
|
}
|