public void ProcessResults_WithFailedResponse_IsProcessed()
        {
            var statProc = new MediaRequestProcessor <Media>
            {
                Type      = MediaType.Status,
                UploadUrl = BaseUrlAndVersion,
                MediaID   = 773000650376548356ul
            };

            List <Media> mediaList = statProc.ProcessResults(MediaStatusFailedResponse);

            Assert.IsNotNull(mediaList);
            Assert.AreEqual(1, mediaList.Count);
            Media media = mediaList.Single();

            Assert.IsNotNull(media);
            Assert.AreEqual(773000650376548356ul, media.MediaID);
            Assert.AreEqual(28276017, media.Size);
            Assert.IsNotNull(media.ProcessingInfo);
            MediaProcessingInfo info = media.ProcessingInfo;

            Assert.AreEqual(MediaProcessingInfo.Failed, info.State);
            Assert.AreEqual(100, info.ProgressPercent);
            Assert.IsNotNull(info.Error);
            MediaError error = info.Error;

            Assert.AreEqual(3, error.Code);
            Assert.AreEqual("UnsupportedMedia", error.Name);
            Assert.AreEqual("Duration 10.minutes+22.seconds+628.milliseconds exceeds max duration of 2.minutes+20.seconds", error.Message);
        }
        public void ProcessResults_WithSucceededResponse_IsProcessed()
        {
            var statProc = new MediaRequestProcessor <Media>
            {
                Type      = MediaType.Status,
                UploadUrl = BaseUrlAndVersion,
                MediaID   = 773017325037580289ul
            };

            List <Media> mediaList = statProc.ProcessResults(MediaStatusSucceededResponse);

            Assert.IsNotNull(mediaList);
            Assert.AreEqual(1, mediaList.Count);
            Media media = mediaList.Single();

            Assert.IsNotNull(media);
            Assert.AreEqual(773017325037580289ul, media.MediaID);
            Assert.AreEqual(7319206, media.Size);
            Assert.AreEqual(86395, media.ExpiresAfterSeconds);
            Assert.AreEqual("video/mp4", media.VideoType);
            Assert.IsNotNull(media.ProcessingInfo);
            MediaProcessingInfo info = media.ProcessingInfo;

            Assert.AreEqual(MediaProcessingInfo.Succeeded, info.State);
            Assert.AreEqual(100, info.ProgressPercent);
        }
        public void ProcessResults_Returns_Empty_Collection_When_Empty_Results()
        {
            var statProc = new MediaRequestProcessor <Media>()
            {
                BaseUrl = BaseUrlAndVersion
            };

            List <Media> stats = statProc.ProcessResults(string.Empty);

            Assert.AreEqual(0, stats.Count);
        }
        public void ProcessResults_Populates_Input_Parameters()
        {
            var statProc = new MediaRequestProcessor <Media>()
            {
                BaseUrl = BaseUrlAndVersion,
                Type    = MediaType.Status,
                Command = "STATUS",
                MediaID = 123,
            };

            List <Media> mediaList = statProc.ProcessResults(MediaStatusInProgressResponse);

            Assert.IsNotNull(mediaList);
            Assert.AreEqual(1, mediaList.Count);
            Media media = mediaList.Single();

            Assert.IsNotNull(media);
            Assert.AreEqual(MediaType.Status, media.Type);
            Assert.AreEqual("STATUS", media.Command);
            Assert.AreEqual(123ul, media.MediaID);
        }
        public void ProcessResults_WithInProgressResponse_IsProcessed()
        {
            var statProc = new MediaRequestProcessor <Media>
            {
                Type      = MediaType.Status,
                UploadUrl = BaseUrlAndVersion,
                MediaID   = 772492064386912256ul
            };

            List <Media> mediaList = statProc.ProcessResults(MediaStatusInProgressResponse);

            Assert.IsNotNull(mediaList);
            Assert.AreEqual(1, mediaList.Count);
            Media media = mediaList.Single();

            Assert.IsNotNull(media);
            Assert.AreEqual(772492064386912256ul, media.MediaID);
            Assert.IsNotNull(media.ProcessingInfo);
            MediaProcessingInfo info = media.ProcessingInfo;

            Assert.AreEqual(MediaProcessingInfo.InProgress, info.State);
            Assert.AreEqual(5, info.CheckAfterSeconds);
            Assert.AreEqual(5, info.ProgressPercent);
        }