Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Reference typos #5155

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; }
}
}
Loading