public void TwoConsecutiveCallsWhichReturnsMessageBuffersShouldNotBeSame() { var message = new MouseDragEventMesssage(MouseEventType.Right, 56, 67, 60, 71); var messageBuffer1 = message.ToBytes(); var messageBuffer2 = message.ToBytes(); Assert.AreNotSame(messageBuffer1, messageBuffer2); }
public void ShouldAbleToBytesFromRetriveVariables() { var message = new MouseDragEventMesssage(MouseEventType.Right, 56, 67, 60, 71); var messageBuffer = new byte[] { 2, 56, 0, 0, 0, 67, 0, 0, 0, 60, 0, 0, 0, 71, 0, 0, 0 }; var messageBufferToCompare = message.ToBytes(); Assert.AreEqual(messageBuffer.Length, messageBufferToCompare.Length); for (var i = 0; i < messageBuffer.Length; i++) { if (messageBuffer[i] != messageBufferToCompare[i]) Assert.Fail("Message contents is not same"); } }
private void OnMouseUp(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: dragEndMouseEventType = MouseEventType.Left; break; case MouseButtons.Middle: dragEndMouseEventType = MouseEventType.Middle; break; case MouseButtons.Right: dragEndMouseEventType = MouseEventType.Right; break; default: return; } dragEndX = e.X; dragEndY = e.Y; byte[] dataToSend; if (dragEndX == dragStartX && dragEndY == dragStartY) { var message = new MouseClickEventMessage(dragEndMouseEventType, (uint)e.X, (uint)e.Y); var messageRdap = new RdapMessage(RdapMessageType.MouseClickEventMessage, message.ToBytes()); dataToSend = messageRdap.ToBytes(); } else { var message = new MouseDragEventMesssage(dragEndMouseEventType, (uint)dragStartX, (uint)dragStartY, (uint)dragEndX, (uint)dragEndY); var messageRdap = new RdapMessage(RdapMessageType.MouseClickEventMessage, message.ToBytes()); dataToSend = messageRdap.ToBytes(); } if (subscriber != null) subscriber.Send(dataToSend, 0, dataToSend.Length); }