public void EventReceived_Paired_TriggersPairedEvent() { // Setup var channel = new Mock <IChannelListener>(); var deviceListener = DeviceListener.Create(channel.Object); PairedEventArgs actualEventArgs = null; deviceListener.Paired += (_, args) => actualEventArgs = args; var myoHandle = new IntPtr(12345); var timestamp = DateTime.UtcNow; var routeEventArgs = new RouteMyoEventArgs( myoHandle, new IntPtr(123), MyoEventType.Paired, timestamp); // Execute channel.Raise(x => x.EventReceived += null, routeEventArgs); // Assert Assert.NotNull(actualEventArgs); Assert.Equal(myoHandle, actualEventArgs.MyoHandle); Assert.Equal(timestamp, actualEventArgs.Timestamp); }
/// <summary> /// Creates a new <see cref="IHub"/> instance. /// </summary> /// <param name="channelListener">The channel listener.</param> /// <returns>A new <see cref="IHub"/> instance.</returns> /// <exception cref="System.ArgumentNullException">Thrown when the channel listener is null.</exception> public static IHub Create(IChannelListener channelListener) { Contract.Requires <ArgumentNullException>(channelListener != null, "channelListener"); Contract.Ensures(Contract.Result <IHub>() != null); return(new Hub(DeviceListener.Create(channelListener))); }
public void EventReceived_EmgData_DoesNotTriggerPairedEvent() { // Setup var channel = new Mock <IChannelListener>(); var deviceListener = DeviceListener.Create(channel.Object); var gotPairedEvent = false; deviceListener.Paired += (_, __) => gotPairedEvent = true; var routeEventArgs = new RouteMyoEventArgs( new IntPtr(123), new IntPtr(123), MyoEventType.Emg, DateTime.UtcNow); // Execute channel.Raise(x => x.EventReceived += null, routeEventArgs); // Assert Assert.False( gotPairedEvent, "Not expecting to get the paired event."); }
public void Create_ValidParameters_NewInstance() { // Setup var channel = new Mock <IChannelListener>(); // Execute var result = DeviceListener.Create(channel.Object); // Assert Assert.NotNull(result); }
public void GetChannelListener_ValidState_SameInstanceAsConstructor() { // Setup var channel = new Mock <IChannelListener>(); var deviceListener = DeviceListener.Create(channel.Object); // Execute var result = deviceListener.ChannelListener; // Assert Assert.Equal(channel.Object, result); }
public void Create_NullChannelListener_ThrowsNullArgumentException() { // Setup // Execute Assert.ThrowsDelegate method = () => DeviceListener.Create(null); // Assert var exception = Assert.Throws <ArgumentNullException>(method); Assert.Equal("channelListener", exception.ParamName); }
/// <summary> /// Initializes a new instance of the <see cref="Hub"/> class. /// </summary> /// <param name="channelListener">The channel listener.</param> /// <exception cref="System.ArgumentNullException">Thrown when the channel listener is null.</exception> protected Hub(IChannelListener channelListener) : this(DeviceListener.Create(channelListener)) { Contract.Requires <ArgumentNullException>(channelListener != null, "channelListener"); }
/// <summary> /// Creates a new <see cref="IHub"/> instance. /// </summary> /// <param name="channelListener">The channel listener.</param> /// <returns>A new <see cref="IHub"/> instance.</returns> /// <exception cref="System.ArgumentNullException">Thrown when the channel listener is null.</exception> public static IHub Create(IChannelListener channelListener) { return(new Hub(DeviceListener.Create(channelListener))); }
/// <summary> /// Initializes a new instance of the <see cref="Hub"/> class. /// </summary> /// <param name="channelListener">The channel listener.</param> /// <exception cref="System.ArgumentNullException">Thrown when the channel listener is null.</exception> protected Hub(IChannelListener channelListener) : this(DeviceListener.Create(channelListener)) { }