Skip to content

Commit

Permalink
Tests: use System.Text.Json in integration tests
Browse files Browse the repository at this point in the history
Use System.Text.Json instead of Newtonsoft.Json in integration
tests.
  • Loading branch information
webwarrior-ws committed Feb 14, 2024
1 parent 343abd5 commit 2356027
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/FX.Tests/RedisIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using FsharpExchangeDotNetStandard;
using FsharpExchangeDotNetStandard.Redis;

using Newtonsoft.Json;
using System.Text.Json;
using NUnit.Framework;
using StackExchange.Redis;

Expand Down Expand Up @@ -33,8 +33,8 @@ private Exchange CreateExchangeAndSendFirstLimitOrder

var tipQuery = new MarketQuery(market, limitOrder.OrderInfo.Side, true);

//e.g. {"Market":{"BuyCurrency":{"Case":"BTC"},"SellCurrency":{"Case":"USD"}},"Side":{"Case":"Buy"},"Tip":true}"
string tipQueryStr = JsonConvert.SerializeObject(tipQuery);
//e.g. {"Market":{"BuyCurrency":"BTC","SellCurrency":"USD"},"Side":"Bid","Tip":true}"
string tipQueryStr = JsonSerializer.Serialize(tipQuery, Serialization.serializationOptions);

using (var redis = ConnectionMultiplexer.Connect("localhost"))
{
Expand Down Expand Up @@ -76,7 +76,7 @@ private Exchange CreateExchangeAndSendFirstLimitOrder
"should have the order content(not null)");

var limitOrderSerialized =
JsonConvert.SerializeObject(limitOrder);
JsonSerializer.Serialize(limitOrder, Serialization.serializationOptions);
Assert.That(order.ToString(),
Is.EqualTo(limitOrderSerialized),
"received order should have same content");
Expand Down Expand Up @@ -129,8 +129,8 @@ public void SendingSecondAndThirdLimitOrderMakesNonTipQueryWorkAfter()

var nonTipQuery = new MarketQuery(market, side, false);

//e.g. {"Market":{"BuyCurrency":{"Case":"BTC"},"SellCurrency":{"Case":"USD"}},"Side":{"Case":"Buy"},"Tip":true}"
string nontipQueryStr = JsonConvert.SerializeObject(nonTipQuery);
//e.g. {"Market":{"BuyCurrency":"BTC","SellCurrency":"USD"},"Side":"Bid","Tip":false}"
string nontipQueryStr = JsonSerializer.Serialize(nonTipQuery, Serialization.serializationOptions);

using (var redis = ConnectionMultiplexer.Connect("localhost"))
{
Expand All @@ -139,7 +139,7 @@ public void SendingSecondAndThirdLimitOrderMakesNonTipQueryWorkAfter()
var values = db.StringGet(nontipQueryStr);
Assert.That(String.IsNullOrEmpty(values), Is.False,
"should have nontip tail(not null) in this market");
var orders = JsonConvert.DeserializeObject<List<string>>(values);
var orders = JsonSerializer.Deserialize<List<string>>(values, Serialization.serializationOptions);
Assert.That(orders.Count, Is.EqualTo(2),
"should have nontip tail of 2 elements in this market now");

Expand All @@ -156,7 +156,7 @@ public void SendingSecondAndThirdLimitOrderMakesNonTipQueryWorkAfter()
Assert.That(order2.IsNull, Is.EqualTo(false),
"should have the second order content(not null)");
var secondLimitOrderSerialized =
JsonConvert.SerializeObject(secondLimitOrder);
JsonSerializer.Serialize(secondLimitOrder, Serialization.serializationOptions);
Assert.That(order2.ToString(),
Is.EqualTo(secondLimitOrderSerialized),
"received second order should have same content");
Expand All @@ -167,7 +167,7 @@ public void SendingSecondAndThirdLimitOrderMakesNonTipQueryWorkAfter()
Assert.That(order3.IsNull, Is.EqualTo(false),
"should have the third order content(not null)");
var thirdLimitOrderSerialized =
JsonConvert.SerializeObject(thirdLimitOrder);
JsonSerializer.Serialize(thirdLimitOrder, Serialization.serializationOptions);
Assert.That(order3.ToString(),
Is.EqualTo(thirdLimitOrderSerialized),
"received second order should have same content");
Expand Down Expand Up @@ -198,8 +198,8 @@ public void TipIsReplaced()

var nonTipQuery = new MarketQuery(market, side, false);

//e.g. {"Market":{"BuyCurrency":{"Case":"BTC"},"SellCurrency":{"Case":"USD"}},"Side":{"Case":"Buy"},"Tip":true}"
string nontipQueryStr = JsonConvert.SerializeObject(nonTipQuery);
//e.g. {"Market":{"BuyCurrency":"BTC","SellCurrency":"USD"},"Side":"Bid","Tip":false}"
string nontipQueryStr = JsonSerializer.Serialize(nonTipQuery, Serialization.serializationOptions);

using (var redis = ConnectionMultiplexer.Connect("localhost"))
{
Expand All @@ -208,7 +208,7 @@ public void TipIsReplaced()
var values = db.StringGet(nontipQueryStr);
Assert.That(String.IsNullOrEmpty(values), Is.False,
"should have nontip tail(not null) in this market");
var orders = JsonConvert.DeserializeObject<List<string>>(values);
var orders = JsonSerializer.Deserialize<List<string>>(values, Serialization.serializationOptions);
Assert.That(orders.Count, Is.EqualTo(1),
"should have nontip tail of 2 elements in this market now");

Expand All @@ -222,7 +222,7 @@ public void TipIsReplaced()
Assert.That(theOrder.IsNull, Is.EqualTo(false),
"should have the second order content(not null)");
var firstLimitOrderSerialized =
JsonConvert.SerializeObject(firstLimitOrder);
JsonSerializer.Serialize(firstLimitOrder, Serialization.serializationOptions);
Assert.That(theOrder.ToString(),
Is.EqualTo(firstLimitOrderSerialized),
"received second order should have same content");
Expand Down

0 comments on commit 2356027

Please sign in to comment.