I tried doing the same testing a while back with raw strings but is was more of a hassle than it was worth. What I found to be a good testing methodology is to assemble a class and then serialize it, like so:
PubSubMessage fake_message = new PubSubMessage
{
type = PubSubType.MESSAGE.ToString(),
data = new PubSubMessageData
{
topic = string.Empty,
message = string.Empty
}
};
PubSubSubscriptionsMessage fake_sub_message = new PubSubSubscriptionsMessage
{
user_name = "dallas",
display_name = "dallas",
channel_name = "twitch",
user_id = "44322889",
channel_id = "12826",
time = DateTime.Parse("2015-12-19T16:39:57-08:00"),
sub_plan = "1000",
sub_plan_name = "Mr_Woodchuck - Channel Subscription (mr_woodchuck)",
months = 9,
context = "resub",
sub_message = new PubSubSubscriptionsSubMessage
{
message = "A Twitch baby is born! KappaHD",
emotes = new List<PubSubEmotes>
{
new PubSubEmotes
{
start = 7,
end = 23,
id = "2867"
}
}
}
};
fake_message.data.topic = "channel-subscribe-events-v1.44322889";
fake_message.data.message = JsonConvert.SerializeObject(fake_sub_message);
string fake_message_string = JsonConvert.SerializeObject(fake_message);
Then all you need to do is deserialize the string like normal. I personally find this much more flexible and much easier to read.