Read() public method

Reads from the stream.
public Read ( ) : IBusinessObject>.ConcurrentDictionary
return IBusinessObject>.ConcurrentDictionary
コード例 #1
0
 public void Test_Read_WhenWrittenWithListOfKeyValuePairs_ShouldStillReturnEquivalentConcurrentDictionary()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadClassDefsNoUIDef();
     var myBo = new MyBO();
     var businessObjects = new List<KeyValuePair<Guid, IBusinessObject>> { new KeyValuePair<Guid, IBusinessObject>(myBo.ID.GetAsGuid(), myBo) };
     var writeStream = new MemoryStream();
     new BinaryFormatter().Serialize(writeStream, businessObjects);
     BORegistry.BusinessObjectManager = new BusinessObjectManager();
     var loadedDataStore = new DataStoreInMemory();
     writeStream.Seek(0, SeekOrigin.Begin);
     var reader = new DataStoreInMemoryBinaryReader(writeStream);
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, businessObjects.Count);
     //---------------Execute Test ----------------------
     loadedDataStore.AllObjects = reader.Read();
     //---------------Test Result -----------------------
     Assert.AreEqual(1, loadedDataStore.Count);
 }
コード例 #2
0
 public void Test_Read()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadClassDefsNoUIDef();
     DataStoreInMemory savedDataStore = new DataStoreInMemory();
     savedDataStore.Add(new MyBO());
     MemoryStream writeStream = new MemoryStream();
     DataStoreInMemoryBinaryWriter writer = new DataStoreInMemoryBinaryWriter(writeStream);
     writer.Write(savedDataStore);
     BORegistry.BusinessObjectManager = new BusinessObjectManager();
     DataStoreInMemory loadedDataStore = new DataStoreInMemory();
     writeStream.Seek(0, SeekOrigin.Begin);
     DataStoreInMemoryBinaryReader reader = new DataStoreInMemoryBinaryReader(writeStream);
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, savedDataStore.Count);
     //---------------Execute Test ----------------------
     loadedDataStore.AllObjects = reader.Read();
     //---------------Test Result -----------------------
     Assert.AreEqual(1, loadedDataStore.Count);
 }