public void TextContent_GetBytes_Returns_Correct_Bytes() { var sourceText = "£$€abc123XYZ°©"; foreach (var encoding in new Encoding[] { Encoding.Default, Encoding.UTF7, Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode, Encoding.UTF32 }) { var noPreamble = encoding.GetBytes(sourceText); var withPreamble = encoding.GetPreamble().Concat(noPreamble); var tcNoPreamble = new TextContent() { Content = sourceText, Encoding = encoding, HadPreamble = false }; var tcWithPreamble = new TextContent() { Content = sourceText, Encoding = encoding, HadPreamble = true }; Assert.IsTrue(noPreamble.SequenceEqual(tcNoPreamble.GetBytes(includePreamble: false))); Assert.IsTrue(noPreamble.SequenceEqual(tcNoPreamble.GetBytes(includePreamble: true))); Assert.IsTrue(noPreamble.SequenceEqual(tcWithPreamble.GetBytes(includePreamble: false))); Assert.IsTrue(withPreamble.SequenceEqual(tcWithPreamble.GetBytes(includePreamble: true))); } }