I created my own serializer, here is the code:
public class BackgroundJobInfoSerializer : IBackgroundJobInfoSerializer
{
private static readonly DataContractSerializer Serializer =
new DataContractSerializer(typeof(BackgroundJobInfo),
null,
int.MaxValue,
false,
false,
new MongoDbSurrogate());
public string Serialize(BackgroundJobInfo info)
{
if (info == null)
{
throw new ArgumentNullException("info", BackgroundJobsLocalization.BackgroundJobInfoIsNull);
}
var stringBuilder = new StringBuilder();
using (var stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
{
var writer = XmlWriter.Create(stringWriter);
Serializer.WriteObject(writer, info);
writer.Flush();
}
return stringBuilder.ToString();
}
public BackgroundJobInfo Deserialize(string info){...}
Now I would like to create a unit test. But I'm wondering how to test it?
What are common test cases should I check to be ensure that everything works fine?