public void CreateAmqpSerializerWithDefaultSerializerIfMessageContentTypeWasNotFilled() { var serializers = GetAmqpSerializers(); var message = A.Fake <IMessage>(); var sut = new AmqpSerializerFactory(new ReadOnlyDictionary <string, IAmqpSerializer>(serializers)); IAmqpSerializer serializer = sut.CreateSerializer(message); serializer.Should().BeOfType <SimpleSerializer>(because: "factory should return default serializer"); }
public void DefaultSerializerShouldBeChooIfSerializerByContentTypeWasNowFound() { var serializers = GetAmqpSerializers(); var message = A.Fake <IMessage>(); A.CallTo(() => message.Headers).Returns(new Dictionary <string, string> { { "content-type", "application/x-binary" } }); var sut = new AmqpSerializerFactory(new ReadOnlyDictionary <string, IAmqpSerializer>(serializers)); IAmqpSerializer serializer = sut.CreateSerializer(message); serializer.Should().BeOfType <SimpleSerializer>(because: "factory should return default serializer"); }
public void CreateAmqpSerializerWithCustomSerializerDeterminedByContentType() { var serializers = GetAmqpSerializers(); var message = A.Fake <IMessage>(); A.CallTo(() => message.Headers).Returns(new Dictionary <string, string> { { "content-type", "application/json" } }); var sut = new AmqpSerializerFactory(new ReadOnlyDictionary <string, IAmqpSerializer>(serializers)); IAmqpSerializer serializer = sut.CreateSerializer(message); serializer.Should().BeOfType <JsonSerializer>(because: "factory should not return default serializer"); }