public void ToXml2CallsSerializeToStringWithName() { ResetSeralizers(); var serializerMocks = GetSerializerMocks(); Serializer.SetXmlSerializers(serializerMocks.Values.Select(v => v.Object)); var toSerialize = new Type1ForSerializer(); var xml = toSerialize.ToXml(typeof(Type2ForSerializer), "notdefault"); serializerMocks["default"].Verify(m => m.SerializeToString(It.IsAny <object>(), typeof(Type1ForSerializer)), Times.Never); serializerMocks["default"].Verify(m => m.SerializeToString(It.IsAny <object>(), typeof(Type2ForSerializer)), Times.Never); serializerMocks["notdefault"].Verify(m => m.SerializeToString(It.IsAny <object>(), typeof(Type1ForSerializer)), Times.Never); serializerMocks["notdefault"].Verify(m => m.SerializeToString(It.IsAny <object>(), typeof(Type2ForSerializer)), Times.Once); }
public void ToXml4CallsSerializeToStreamWithName() { ResetSeralizers(); var serializerMocks = GetSerializerMocks(); Serializer.SetXmlSerializers(serializerMocks.Values.Select(v => v.Object)); using var stream = new MemoryStream(); var toSerialize = new Type1ForSerializer(); toSerialize.ToXml(typeof(Type2ForSerializer), stream, "notdefault"); serializerMocks["default"].Verify(m => m.SerializeToStream(stream, It.IsAny <object>(), typeof(Type1ForSerializer)), Times.Never); serializerMocks["default"].Verify(m => m.SerializeToStream(stream, It.IsAny <object>(), typeof(Type2ForSerializer)), Times.Never); serializerMocks["notdefault"].Verify(m => m.SerializeToStream(stream, It.IsAny <object>(), typeof(Type1ForSerializer)), Times.Never); serializerMocks["notdefault"].Verify(m => m.SerializeToStream(stream, It.IsAny <object>(), typeof(Type2ForSerializer)), Times.Once); }