예제 #1
0
        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));
        }
예제 #2
0
 public void ThrowExceptionIfCameraIsntOnlineAndStreaming(NestCameraJson cameraJson)
 {
     if (IsOffline(cameraJson))
     {
         throw new NestCameraOfflineException(cameraJson.LastIsOnlineChange);
     }
 }
예제 #3
0
 public bool IsOffline(NestCameraJson cameraJson)
 {
     return(!cameraJson.IsOnline || !cameraJson.IsStreaming);
 }
예제 #4
0
 public byte[] GetSnapshotJpg(NestCameraJson cameraJson)
 {
     return(httpClient.GetByteArrayAsync(cameraJson.SnapshotUrl).Result);
 }