public void EnumValueIsSerializedAsString(string encodingWebName) { var encoding = Encoding.GetEncoding(encodingWebName); // arrange serializer.SpecifyEncoding(encoding); serializer.SerializeEnumAsStrings(true); // act var message = serializer.Serialize(new Message { Messages = new[] { new SomeMessageWithEnums { SomeEnum = SomeEnumValue.IAmTheValueTwo } } }); // assert encoding.GetString(message.Body).ShouldContain(SomeEnumValue.IAmTheValueTwo.ToString()); }
/// <summary> /// Configure the serializer to serialize the enums as string. /// </summary> public JsonSerializationOptions SerializeEnumAsStrings(bool camelCaseText) { jsonMessageSerializer.SerializeEnumAsStrings(camelCaseText); return(this); }