Skip to content

Commit

Permalink
fix Refernce typos (#5155)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Jul 22, 2024
1 parent 1fcc717 commit de8c4cc
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ public void SerializePayloadShouldNotPickDefaultSettings(int version)

var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null);
classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop);
classWithSelfReferencingLoop.InfiniteRefernce!.InfiniteRefernce = classWithSelfReferencingLoop;
classWithSelfReferencingLoop.InfiniteReference!.InfiniteReference = classWithSelfReferencingLoop;

string serializedPayload = _jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop, version);
if (version <= 1)
{
Assert.AreEqual("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}", serializedPayload);
Assert.AreEqual("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteReference\":{}}}", serializedPayload);
}
else
{
Assert.AreEqual($"{{\"Version\":{version},\"MessageType\":\"dummy\",\"Payload\":{{\"InfiniteRefernce\":{{}}}}}}", serializedPayload);
Assert.AreEqual($"{{\"Version\":{version},\"MessageType\":\"dummy\",\"Payload\":{{\"InfiniteReference\":{{}}}}}}", serializedPayload);
}

JsonConvert.DefaultSettings = null;
Expand All @@ -76,7 +76,7 @@ public void DeserializeMessageShouldNotPickDefaultSettings()
PreserveReferencesHandling = PreserveReferencesHandling.All,
};

Message message = _jsonDataSerializer.DeserializeMessage("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}");
Message message = _jsonDataSerializer.DeserializeMessage("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteReference\":{}}}");
Assert.AreEqual("dummy", message?.MessageType);
JsonConvert.DefaultSettings = null;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public void DeserializePayloadIsUnaffectedByJsonConverterDefaultSettings(int ver
};

// This line should deserialize properly
Message message = _jsonDataSerializer.DeserializeMessage($"{{\"Version\":\"{version}\",\"MessageType\":\"dummy\",\"Payload\":{{\"InfiniteRefernce\":{{}}}}}}");
Message message = _jsonDataSerializer.DeserializeMessage($"{{\"Version\":\"{version}\",\"MessageType\":\"dummy\",\"Payload\":{{\"InfiniteReference\":{{}}}}}}");


//restore the default settings to null
Expand All @@ -150,7 +150,7 @@ public void SerializePayloadShouldSerializeAnObjectWithSelfReferencingLoop()
{
var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null);
classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop);
classWithSelfReferencingLoop.InfiniteRefernce!.InfiniteRefernce = classWithSelfReferencingLoop;
classWithSelfReferencingLoop.InfiniteReference!.InfiniteReference = classWithSelfReferencingLoop;

// This line should not throw exception
_jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop);
Expand All @@ -161,15 +161,15 @@ public void DeserializeShouldDeserializeAnObjectWhichHadSelfReferencingLoopBefor
{
var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null);
classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop);
classWithSelfReferencingLoop.InfiniteRefernce!.InfiniteRefernce = classWithSelfReferencingLoop;
classWithSelfReferencingLoop.InfiniteReference!.InfiniteReference = classWithSelfReferencingLoop;

var json = _jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop);

// This line should deserialize properly
var result = _jsonDataSerializer.Deserialize<ClassWithSelfReferencingLoop>(json, 1)!;

Assert.AreEqual(typeof(ClassWithSelfReferencingLoop), result.GetType());
Assert.IsNull(result.InfiniteRefernce);
Assert.IsNull(result.InfiniteReference);
}

[TestMethod]
Expand Down Expand Up @@ -255,9 +255,9 @@ public class ClassWithSelfReferencingLoop
{
public ClassWithSelfReferencingLoop(ClassWithSelfReferencingLoop? ir)
{
InfiniteRefernce = ir;
InfiniteReference = ir;
}

public ClassWithSelfReferencingLoop? InfiniteRefernce { get; set; }
public ClassWithSelfReferencingLoop? InfiniteReference { get; set; }
}
}

0 comments on commit de8c4cc

Please sign in to comment.