internal void CanSerializeAndDeserialize_DataRequests() { // Arrange var serializer = new MsgPackRequestSerializer(); var symbol = new Symbol("AUD/USD", new Venue("FXCM")); var dateTime = StubZonedDateTime.UnixEpoch(); var query = new Dictionary <string, string> { { "DataType", "Tick[]" }, { "Symbol", symbol.ToString() }, { "FromDateTime", dateTime.ToIso8601String() }, { "ToDateTime", dateTime.ToIso8601String() }, }; var request = new DataRequest( query, Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act var packed = serializer.Serialize(request); var unpacked = (DataRequest)serializer.Deserialize(packed); // Assert Assert.Equal(request, unpacked); Assert.Equal("Tick[]", unpacked.Query["DataType"]); Assert.Equal(symbol.ToString(), unpacked.Query["Symbol"]); Assert.Equal(dateTime.ToIso8601String(), unpacked.Query["FromDateTime"]); Assert.Equal(dateTime.ToIso8601String(), unpacked.Query["ToDateTime"]); this.Output.WriteLine(Convert.ToBase64String(packed)); this.Output.WriteLine(Encoding.UTF8.GetString(packed)); }
internal void CanSerializeAndDeserialize_ConnectRequests() { // Arrange var serializer = new MsgPackRequestSerializer(); var request = new Connect( new ClientId("Trader-001"), "None", Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act var packed = serializer.Serialize(request); var unpacked = (Connect)serializer.Deserialize(packed); // Assert Assert.Equal(request, unpacked); Assert.Equal("Trader-001", unpacked.ClientId.Value); }
internal void CanSerializeAndDeserialize_DisconnectRequests() { // Arrange var serializer = new MsgPackRequestSerializer(); var request = new Disconnect( new ClientId("Trader-001"), SessionId.Create(new ClientId("Trader-001"), StubZonedDateTime.UnixEpoch(), "None"), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act var packed = serializer.Serialize(request); var unpacked = (Disconnect)serializer.Deserialize(packed); // Assert Assert.Equal(request, unpacked); Assert.Equal(new ClientId("Trader-001"), unpacked.ClientId); Assert.Equal("Trader-001-e5db3dad8222a27e5d2991d11ad65f0f74668a4cfb629e97aa6920a73a012f87", unpacked.SessionId.Value); }