public void OpenExistingPositiveTest() { P2PMessageQueue originalQueue = new P2PMessageQueue(true); Assert.IsNotNull(originalQueue); P2PMessageQueue copyQueue = P2PMessageQueue.OpenExisting(false, GetCurrentProcessHandle(), originalQueue.Handle); Assert.IsNotNull(copyQueue); }
public void OpenExistingBadHandleTest() { ArgumentException expected = null; // create a "valid" (non zero, non negative 1) handle IntPtr validHandleValue = new IntPtr(0x8000000); IntPtr zeroHandle = IntPtr.Zero; IntPtr minusOneHandle = new IntPtr(-1); try { P2PMessageQueue.OpenExisting(true, zeroHandle, validHandleValue); } catch (ArgumentException ex) { expected = ex; } Assert.IsNotNull(expected); expected = null; try { P2PMessageQueue.OpenExisting(true, minusOneHandle, validHandleValue); } catch (ArgumentException ex) { expected = ex; } Assert.IsNotNull(expected); expected = null; try { P2PMessageQueue.OpenExisting(true, validHandleValue, zeroHandle); } catch (ArgumentException ex) { expected = ex; } Assert.IsNotNull(expected); expected = null; try { P2PMessageQueue.OpenExisting(true, validHandleValue, minusOneHandle); } catch (ArgumentException ex) { expected = ex; } Assert.IsNotNull(expected); }