A class that writes the contents of a DataStoreInMemory to a binary stream.
 public void Test_Construct()
 {
     //---------------Set up test pack-------------------
     DataStoreInMemory dataStore = new DataStoreInMemory();
     //---------------Assert PreConditions---------------            
     //---------------Execute Test ----------------------
     DataStoreInMemoryBinaryWriter writer = new DataStoreInMemoryBinaryWriter(new MemoryStream());
     //---------------Test Result -----------------------
     
     //---------------Tear Down -------------------------          
 }
 public void Test_Write()
 {
     //---------------Set up test pack-------------------
     DataStoreInMemory dataStore = new DataStoreInMemory();
     dataStore.Add(new Car());
     MemoryStream stream = new MemoryStream();
     DataStoreInMemoryBinaryWriter writer = new DataStoreInMemoryBinaryWriter(stream);
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, dataStore.Count);
     Assert.AreEqual(0, stream.Length);
     //---------------Execute Test ----------------------
     writer.Write(dataStore);
     //---------------Test Result -----------------------
     Assert.AreNotEqual(0, stream.Length);
 }
 public void Test_Write_WithConcurrentDictionary()
 {
     //---------------Set up test pack-------------------
     var dataStore = new DataStoreInMemory();
     dataStore.Add(new Car());
     var businessObjects = dataStore.AllObjects;
     var stream = new MemoryStream();
     var writer = new DataStoreInMemoryBinaryWriter(stream);
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, dataStore.Count);
     Assert.AreEqual(0, stream.Length);
     //---------------Execute Test ----------------------
     writer.Write(businessObjects);
     //---------------Test Result -----------------------
     Assert.AreNotEqual(0, stream.Length);
 }
 public void Test_Write_WithDictionary()
 {
     //---------------Set up test pack-------------------
     var car = new Car();
     var businessObjects = new Dictionary<Guid, IBusinessObject> {{car.ID.GetAsGuid(), car}};
     var stream = new MemoryStream();
     var writer = new DataStoreInMemoryBinaryWriter(stream);
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, businessObjects.Count);
     Assert.AreEqual(0, stream.Length);
     //---------------Execute Test ----------------------
     writer.Write(businessObjects);
     //---------------Test Result -----------------------
     Assert.AreNotEqual(0, stream.Length);
 }
 public void Test_Read_WhenWrittenWithDictionary_ShouldStillReturnEquivalentConcurrentDictionary()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadClassDefsNoUIDef();
     var myBo = new MyBO();
     var businessObjects = new Dictionary<Guid, IBusinessObject> { { myBo.ID.GetAsGuid(), myBo } };
     var writeStream = new MemoryStream();
     var writer = new DataStoreInMemoryBinaryWriter(writeStream);
     writer.Write(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);
 }
 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);
 }