public async Task FormatTypeAsExpected_Custom() { var serializer = new JsonSerializer(new CustomTypeNameConventionBuilder() .AddWithShortName <SomeType>() .GetConvention()); const string expectedTypeName = "SomeType"; var message = new Message(new Dictionary <string, string>(), new SomeType()); var transportMessage = await serializer.Serialize(message); var type = transportMessage.Headers.GetValue(Headers.Type); Console.WriteLine($@" Serialized type name: {type} Expected type name: {expectedTypeName} "); var roundtrippedMessage = await serializer.Deserialize(transportMessage); Assert.That(type, Is.EqualTo(expectedTypeName)); Assert.That(roundtrippedMessage.Body, Is.TypeOf <SomeType>()); }
public async Task WorksWithoutFullTypeNameHandlingToo() { var simpleSerializer = new JsonSerializer(new JsonSerializerSettings()); var message = new RandomMessage("hei allihoppa"); var transportMessage = await simpleSerializer.Serialize(new Message(new Dictionary <string, string>(), message)); var roundtrippedMessage = (await simpleSerializer.Deserialize(transportMessage)).Body; Assert.That(roundtrippedMessage, Is.TypeOf <RandomMessage>()); }
public async Task FormatTypeAsExpected_Default() { var expectedTypeName = typeof(SomeType).GetSimpleAssemblyQualifiedName(); var serializer = new JsonSerializer(new SimpleAssemblyQualifiedMessageTypeNameConvention()); var message = new Message(new Dictionary <string, string>(), new SomeType()); var transportMessage = await serializer.Serialize(message); var type = transportMessage.Headers.GetValue(Headers.Type); Console.WriteLine($@" Serialized type name: {type} Expected type name: {expectedTypeName} "); var roundtrippedMessage = await serializer.Deserialize(transportMessage); Assert.That(type, Is.EqualTo(expectedTypeName)); Assert.That(roundtrippedMessage.Body, Is.TypeOf <SomeType>()); }
protected override void SetUp() { _serializer = new JsonSerializer(); }
protected override void SetUp() { _serializer = new JsonSerializer(new SimpleAssemblyQualifiedMessageTypeNameConvention()); }
protected override void SetUp() { _serializer = new JsonSerializer(new DefaultMessageTypeMapper()); }