Exemple #1
0
 internal static ITusStore WithExistingFile(this ITusStore store, string fileId, Func <CallInfo, long?> uploadLength, Func <CallInfo, long> uploadOffset)
 {
     store.FileExistAsync(fileId, Arg.Any <CancellationToken>()).Returns(true);
     store.GetUploadLengthAsync(fileId, Arg.Any <CancellationToken>()).Returns(uploadLength);
     store.GetUploadOffsetAsync(fileId, Arg.Any <CancellationToken>()).Returns(uploadOffset);
     return(store);
 }
Exemple #2
0
        /// <summary>
        /// Check if the <see cref="ITusFile"/> has been completely uploaded.
        /// </summary>
        /// <param name="file">The file to check</param>
        /// <param name="store">The store responsible for handling the file</param>
        /// <param name="cancellationToken">The cancellation token to use when cancelling</param>
        /// <returns>True if the file is completed, otherwise false</returns>
        public static async Task <bool> IsCompleteAsync(this ITusFile file, ITusStore store, CancellationToken cancellationToken)
        {
            var length = store.GetUploadLengthAsync(file.Id, cancellationToken);
            var offset = store.GetUploadOffsetAsync(file.Id, cancellationToken);

            await Task.WhenAll(length, offset);

            return(length.Result == offset.Result);
        }