public MFTestResults LargeBufferTest_LargeData() { MFTestResults res = MFTestResults.Pass; LargeBuffer lb = null; try { LargeBufferMarshaller lbm = new LargeBufferMarshaller(321); lb = new LargeBuffer(1024 * 1024); int len = lb.Bytes.Length - 1; for (int i = 0; i < 1000; i++) { lb.Bytes[len - i] = (byte)i; } lbm.MarshalBuffer(lb); lbm.UnMarshalBuffer(ref lb); for (int i = 0; i < 1000; i++) { if ((byte)i != lb.Bytes[i]) { Log.Comment("UnMarshalBuffer should have swapped the bytes"); res = MFTestResults.Fail; break; } } } catch (Exception e) { Log.Exception("Exception", e); res = MFTestResults.Fail; } finally { if (lb != null) { lb.Dispose(); } } return(res); }
public MFTestResults LargeBufferTest_DifferentSizeBuff() { MFTestResults res = MFTestResults.Pass; LargeBuffer lb = null; LargeBuffer lb2 = null; try { lb = new LargeBuffer(1000); lb2 = new LargeBuffer(100); LargeBufferMarshaller lbm = new LargeBufferMarshaller(123); lbm.MarshalBuffer(lb); lbm.UnMarshalBuffer(ref lb2); if (lb.Bytes.Length != lb2.Bytes.Length) { Log.Comment("The UnMarshalBuffer call should have changed the byte length of lb2"); res = MFTestResults.Fail; } } catch (Exception e) { Log.Exception("Exception", e); res = MFTestResults.Fail; } finally { if (lb != null) { lb.Dispose(); } if (lb2 != null) { lb2.Dispose(); } } return(res); }
public MFTestResults LargeBufferTest_TestEvent() { MFTestResults res = MFTestResults.Pass; try { LargeBufferMarshaller lbm = new LargeBufferMarshaller(321); LargeBuffer lb = new LargeBuffer(100); LargeBufferMarshaller.OnLargeBufferRequest += new LargeBufferMarshaller.LargeBufferEventHandler(OnLargeBufferEvent); m_evtLargeBuffer.Reset(); lbm.MarshalBuffer(lb); if (!m_evtLargeBuffer.WaitOne(5000, true)) { Log.Comment("Did not receive LargeBufferMarshaller event"); res = MFTestResults.Fail; } else if (m_eventId != 321) { Log.Comment("Wrong marshallerID in event"); res = MFTestResults.Fail; } lb.Dispose(); LargeBufferMarshaller.OnLargeBufferRequest -= new LargeBufferMarshaller.LargeBufferEventHandler(OnLargeBufferEvent); } catch (Exception e) { Log.Exception("Exception", e); res = MFTestResults.Fail; } return(res); }