Writes the contents of a DataStoreInMemory to an xml stream
 public void Construct()
 {
     //---------------Set up test pack-------------------
     //---------------Assert PreConditions---------------            
     //---------------Execute Test ----------------------
     var writer = new DataStoreInMemoryXmlWriter();
     //---------------Test Result -----------------------
     
     //---------------Tear Down -------------------------          
 }
 public void Write()
 {
     //---------------Set up test pack-------------------
     var dataStore = new DataStoreInMemory();
     dataStore.Add(new Car());
     var stream = new MemoryStream();
     var writer = new DataStoreInMemoryXmlWriter();
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, dataStore.Count);
     Assert.AreEqual(0, stream.Length);
     //---------------Execute Test ----------------------
     writer.Write(stream, dataStore);
     //---------------Test Result -----------------------
     Assert.AreNotEqual(0, stream.Length);
 }
 public void Write_WithXmlWriterSettings()
 {
     //---------------Set up test pack-------------------
     var dataStore = new DataStoreInMemory();
     dataStore.Add(new Car());
     var stream = new MemoryStream();
     var xmlWriterSettings = new XmlWriterSettings();
     xmlWriterSettings.ConformanceLevel = ConformanceLevel.Auto;
     xmlWriterSettings.NewLineOnAttributes = true;
     var writer = new DataStoreInMemoryXmlWriter(xmlWriterSettings);
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, dataStore.Count);
     Assert.AreEqual(0, stream.Length);
     //---------------Execute Test ----------------------
     writer.Write(stream, dataStore);
     //---------------Test Result -----------------------
     Assert.AreNotEqual(0, stream.Length);
 }
 public void Write_ToString()
 {
     //---------------Set up test pack-------------------
     var dataStore = new DataStoreInMemory();
     dataStore.Add(new Car());
     var writer = new DataStoreInMemoryXmlWriter();
     var sb = new StringBuilder();
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, dataStore.Count);
     Assert.AreEqual(0, sb.Length);
     //---------------Execute Test ----------------------
     writer.Write(sb, dataStore);
     //---------------Test Result -----------------------
     Assert.AreNotEqual(0, sb.Length);
 }
 private MemoryStream GetStreamForDataStore(DataStoreInMemory dataStore)
 {
     var writeStream = new MemoryStream();
     var writer = new DataStoreInMemoryXmlWriter();
     writer.Write(writeStream, dataStore);
     writeStream.Seek(0, SeekOrigin.Begin);
     return writeStream;
 }
 private MemoryStream GetStreamForBusinessObject(MyBO businessObject)
 {
     var savedDataStore = new DataStoreInMemory();
     savedDataStore.Add(businessObject);
     var writeStream = new MemoryStream();
     var writer = new DataStoreInMemoryXmlWriter();
     writer.Write(writeStream, savedDataStore);
     writeStream.Seek(0, SeekOrigin.Begin);
     return writeStream;
 }
        public void Read_FromString()
        {
            //---------------Set up test pack-------------------
            var dataStore = new DataStoreInMemory();
            dataStore.Add(new Car());
            var writer = new DataStoreInMemoryXmlWriter();
            var sb = new StringBuilder();
            writer.Write(sb, dataStore);
            var xml = sb.ToString();

            var reader = new ObjectTreeXmlReader();
            //---------------Assert Precondition----------------
            Assert.AreEqual(1, dataStore.Count);
            Assert.Greater(xml.Length, 100);
            //---------------Execute Test ----------------------
            var businessObjects = reader.Read(xml);
            //---------------Test Result -----------------------
            Assert.AreEqual(1, businessObjects.Count());
        }