Пример #1
0
        public static IXMLMessageSerializer CreateXMLSerializer(Type messageType)
        {
            IXMLMessageSerializer result = new XMLMessageSerializer(new StreamAdapter(), new XMLSerializeAdapter());
             result.Initialize(messageType);

             return result;
        }
Пример #2
0
        public void A_MessageSerializer_will_close_its_IStreamAdapter_when_it_is_disposed()
        {
            SetupResult.For(_streamAdapter.IsOpen)
            .Return(true);

             using (_mocks.Record())
             {
            _streamAdapter.Close();
             }

             using (_mocks.Playback())
             {
            using (IXMLMessageSerializer theUnit = new XMLMessageSerializer(_streamAdapter, _serializeAdapter))
            {
            }
             }
        }
Пример #3
0
        public void Should_deserialize_an_xml_document_and_return_the_rehydrated_object()
        {
            using (_mocks.Record())
             {
            _streamAdapter.WriteString("xmlDocument");
            SetupResult
               .For(_serializeAdapter.Deserialize(_streamAdapter))
               .Return(Guid.NewGuid());
             }

             using (_mocks.Playback())
             {
            using (IXMLMessageSerializer theUnit = new XMLMessageSerializer(_streamAdapter, _serializeAdapter))
            {
               theUnit.Deserialize("xmlDocument");
            }
             }
        }
Пример #4
0
        public void Should_serialize_an_object_to_xml_then_return_the_document_as_a_string()
        {
            using (_mocks.Record())
             {
            SetupResult
               .For(_streamAdapter.Stream)
               .Return(new MemoryStream());
            SetupResult
               .For(_streamAdapter.ReadString())
               .Return("xmlText");
             }

             using (_mocks.Playback())
             {
            using (IXMLMessageSerializer theUnit = new XMLMessageSerializer(_streamAdapter, _serializeAdapter))
            {
               theUnit.Serialize(Guid.NewGuid());
            }
             }
        }
Пример #5
0
 public void A_new_MessageSerializer_can_be_initialize_with_an_IStreamAdapter_and_an_ISerializeAdapter()
 {
     using (IXMLMessageSerializer theUnit = new XMLMessageSerializer(_streamAdapter, _serializeAdapter))
      {
      }
 }