public void Check_MotionSensor_Reports_Motion_Data() { // Arrange var cmd = Helpers .CreateCommand("report", "motion", "158d00011c0", 52754, new Dictionary <string, object> { { "status", "motion" } }); // Act MotionSensor device = _fixture.GetDeviceByCommand <MotionSensor>(cmd); var motionRaised = false; device.OnMotion += (_, args) => { motionRaised = true; }; var timeDiff = DateTime.Now - device.MotionDate.Value; device.ParseData(ResponseCommand.FromString(cmd).Data); // Assert Assert.Equal("motion", device.Type); Assert.Equal("158d00011c0", device.Sid); Assert.Equal("motion", device.Status); Assert.True(timeDiff <= TimeSpan.FromSeconds(1)); Assert.True(motionRaised); }
public void Check_MotionSensor_Reports_NoMotion_Data() { // Arrange var cmd = Helpers .CreateCommand("report", "motion", "158d00011c0", 52754, new Dictionary <string, object> { { "no_motion", "120" } }); // Act MotionSensor device = _fixture.GetDeviceByCommand <MotionSensor>(cmd); var noMotionRaised = false; var moMotionSeconds = 0; device.OnNoMotion += (_, args) => { noMotionRaised = true; moMotionSeconds = args.Seconds; }; device.ParseData(ResponseCommand.FromString(cmd).Data); // Assert Assert.Equal("motion", device.Type); Assert.Equal("158d00011c0", device.Sid); Assert.Equal("no motion", device.Status); Assert.True(noMotionRaised); Assert.Equal(120, device.NoMotion); }