/// <summary> /// Verifies the progress status. /// </summary> /// <param name="progress">The upload progress.</param> /// <param name="fileLength">The file length.</param> private void VerifyProgressStatus(TransferProgress progress, long fileLength) { Assert.Equal(fileLength, progress.TotalFileLength); Assert.True(1 <= progress.TotalSegmentCount, "UploadProgress: Unexpected value for TotalSegmentCount"); Assert.Equal(progress.TotalFileLength, progress.TransferredByteCount); long uploadedByteSum = 0; for (int i = 0; i < progress.TotalSegmentCount; i++) { var segmentProgress = progress.GetSegmentProgress(i); Assert.False(segmentProgress.IsFailed, string.Format("UploadProgress: Segment {0} seems to have failed", i)); Assert.Equal(i, segmentProgress.SegmentNumber); // there are times where the operation will complete successfully before the final bytes update call back can run. // We are not as concerned with the progress state being exactly correct, since validation of transferred bytes // should really be checked against the actual file/folder being transfered and not on the progress callback. // TODO: In the future, make the callback more robust and ensure that it always updates to include the final state. Assert.InRange(segmentProgress.TransferredByteCount, segmentProgress.Length * .8, segmentProgress.Length); uploadedByteSum += segmentProgress.TransferredByteCount; } Assert.Equal(progress.TransferredByteCount, uploadedByteSum); }