public void UnknownType() { using (var ms = new MemoryStream()) { var s = new BuiltInTypesSerializer(); Assert.False(s.CanSerialize(ms, null)); using (var bw = new BinaryWriter(ms, Encoding.UTF8, true)) Assert.Throws <InvalidOperationException>(() => s.Serialize(ms, bw, null)); } }
public void Serialization(object value) { using (var ms = new MemoryStream()) { var s = new BuiltInTypesSerializer(); Assert.True(s.CanSerialize(value, null)); using (var bw = new BinaryWriter(ms, Encoding.UTF8, true)) s.Serialize(value, bw, null); ms.Position = 0; using (var br = new BinaryReader(ms, Encoding.UTF8, true)) Assert.Equal(value, s.Deserialize(br, null)); } }