public static DescribedSerialization ToDescribedSerialization <T>( this T objectToPackageIntoDescribedSerialization, SerializationDescription serializationDescription, TypeMatchStrategy typeMatchStrategy = TypeMatchStrategy.NamespaceAndName, MultipleMatchStrategy multipleMatchStrategy = MultipleMatchStrategy.ThrowOnMultiple, UnregisteredTypeEncounteredStrategy unregisteredTypeEncounteredStrategy = UnregisteredTypeEncounteredStrategy.Default) { return(DomainExtensions.ToDescribedSerializationUsingSpecificFactory( objectToPackageIntoDescribedSerialization, serializationDescription, SerializerFactory.Instance, CompressorFactory.Instance, typeMatchStrategy, multipleMatchStrategy, unregisteredTypeEncounteredStrategy)); }
public static void ToDescribedSerializationUsingSpecificFactory___Null_serializer_factory___Throws() { // Arrange Action action = () => DomainExtensions.ToDescribedSerializationUsingSpecificFactory( A.Dummy <string>(), A.Dummy <SerializerRepresentation>(), null, A.Dummy <SerializationFormat>()); // Act var exception = Record.Exception(action); // Assert exception.Should().NotBeNull(); exception.Should().BeOfType <ArgumentNullException>(); exception.Message.Should().Contain("serializerFactory"); }
public static void ToDescribedSerializationUsingSpecificFactory___Null_compressor_factory___Throws() { // Arrange Action action = () => DomainExtensions.ToDescribedSerializationUsingSpecificFactory( A.Dummy <string>(), A.Dummy <SerializationDescription>(), SerializerFactory.Instance, null); // Act var exception = Record.Exception(action); // Assert exception.Should().NotBeNull(); exception.Should().BeOfType <ArgumentNullException>(); exception.Message.Should().Be("Parameter 'compressorFactory' is null."); }
public static void ToDescribedSerializationWithSpecificFactory___All_valid___Works() { // Arrange var objectToPackageIntoDescribedSerialization = A.Dummy <string>(); var serializerRepresentation = new SerializerRepresentation(SerializationKind.Json, typeof(NullJsonSerializationConfiguration).ToRepresentation(), CompressionKind.None); // Act var describedSerialization = DomainExtensions.ToDescribedSerializationUsingSpecificFactory( objectToPackageIntoDescribedSerialization, serializerRepresentation, SerializerFactory.Instance, SerializationFormat.String); // Assert describedSerialization.Should().NotBeNull(); describedSerialization.Should().BeOfType <StringDescribedSerialization>(); describedSerialization.PayloadTypeRepresentation.Should().Be(objectToPackageIntoDescribedSerialization.GetType().ToRepresentation()); ((StringDescribedSerialization)describedSerialization).SerializedPayload.Should().Be("\"" + objectToPackageIntoDescribedSerialization + "\""); describedSerialization.SerializerRepresentation.Should().Be(serializerRepresentation); }