public void Verify_Camera_Exception_Cases() { var cameraStatus = new NestCameraStatus(); Assert.Throws <NestCameraOfflineException>(() => cameraStatus.ThrowExceptionIfCameraIsntOnlineAndStreaming(new NestCameraJson())); Assert.Throws <NestCameraOfflineException>(() => cameraStatus.ThrowExceptionIfCameraIsntOnlineAndStreaming(new NestCameraJson { IsOnline = true })); Assert.Throws <NestCameraOfflineException>(() => cameraStatus.ThrowExceptionIfCameraIsntOnlineAndStreaming(new NestCameraJson { IsStreaming = true // Probably isn't posible to be streaming and offline...This is a test case I can remove when I gain experience and comfort with this problem area. For now however, I'm validating the API's themselves and making no assumptions. })); var fullyOnlineCamera = new NestCameraJson { IsOnline = true, IsStreaming = true }; cameraStatus.ThrowExceptionIfCameraIsntOnlineAndStreaming(fullyOnlineCamera); Assert.False(cameraStatus.IsOffline(fullyOnlineCamera)); }
public void ThrowExceptionIfCameraIsntOnlineAndStreaming(NestCameraJson cameraJson) { if (IsOffline(cameraJson)) { throw new NestCameraOfflineException(cameraJson.LastIsOnlineChange); } }
public bool IsOffline(NestCameraJson cameraJson) { return(!cameraJson.IsOnline || !cameraJson.IsStreaming); }
public byte[] GetSnapshotJpg(NestCameraJson cameraJson) { return(httpClient.GetByteArrayAsync(cameraJson.SnapshotUrl).Result); }