public async Task LocalFileUploadTest1()
        {
            const string FileName       = "File:Test image.jpg";
            const string FileSHA1       = "81ED69FA2C2BDEEBBA277C326D1AAC9E0E57B346";
            const string ReuploadSuffix = "\n\nReuploaded.";
            var          file           = GetDemoImage();

            try
            {
                await FilePage.UploadAsync(await SiteAsync, file.Item1, FileName, file.Item2, false);
            }
            catch (UploadException ex)
            {
                // Client should rarely be checking like this
                // Usually we should notify the user.
                if (ex.UploadResult.Warnings[0].Key == "exists")
                {
                    // Just re-upload
                    await FilePage.UploadAsync(await SiteAsync, ex.UploadResult, FileName, file.Item2 + ReuploadSuffix, true);
                }
                else
                {
                    throw;
                }
            }
            var fp = new FilePage(await SiteAsync, FileName);
            await fp.RefreshAsync();

            ShallowTrace(fp);
            Assert.True(fp.Exists);
            Assert.Equal(FileSHA1, fp.LastFileRevision.Sha1.ToUpperInvariant());
        }
Example #2
0
        public async Task WpLzhFetchFileTest()
        {
            var site = await WpLzhSiteAsync;
            var file = new FilePage(site, "File:Empress Suiko.jpg");
            await file.RefreshAsync();

            ShallowTrace(file);
            //Assert.True(file.Exists);   //It's on WikiMedia!
            Assert.Equal(58865, file.LastFileRevision.Size);
            Assert.Equal("7aa12c613c156dd125212d85a072b250625ae39f", file.LastFileRevision.Sha1.ToLowerInvariant());
        }