public async Task Fill_empty_wall_list_with_fake_data() { var usersGet = SubstituresForVkApi.UsersGet(); var groupsGet = SubstituresForVkApi.GroupsGet(); var wallList = new WallList(); var filler = new AvailableWallsFiller(usersGet, groupsGet); var info = await filler.FillAsync(wallList); Assert.That(info.Succeed, Is.True); Assert.That(wallList.Items.Count, Is.EqualTo(3)); }
public async Task Fill_empty_wall_list_with_corrupted_users_data() { var usersGet = Substitute.For <IUsersGet>(); usersGet.GetAsync(QueryParameters.No()).ReturnsForAnyArgs(new UsersGetResponse { Content = null }); var groupsGet = SubstituresForVkApi.GroupsGet(); var wallList = new WallList(); var filler = new AvailableWallsFiller(usersGet, groupsGet); var info = await filler.FillAsync(wallList); Assert.That(info.Succeed, Is.False); Assert.That(info.ErrorMessage, Is.Not.Null); }
public async Task Upload_photo_to_server_and_verify_progress() { var uploadServer = SubstituresForVkApi.PhotosGetWallUploadSever(); var saveWallPhoto = SubstituresForVkApi.PhotosSaveWallPhoto(); var ct = CancellationToken.None; var photo = new byte[1024 * 1]; var contentToRecieve = new byte[1024 * 2]; contentToRecieve[233] = byte.MaxValue; contentToRecieve[510] = byte.MaxValue; var progress = new Progress <HttpProgressEventArgs>(); bool progressReportEverCalled = false; int progressPercentage = 0; progress.ProgressChanged += (sender, i) => { progressReportEverCalled = true; progressPercentage = i.ProgressPercentage; }; var fakeMessagehandler = new FakeResponseHandler(); fakeMessagehandler.AddFakeResponse(new Uri("http://upload.uri/"), new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(contentToRecieve) }); var uploader = new VkUploader(uploadServer, saveWallPhoto, fakeMessagehandler); var info = await uploader.TryUploadPhotoToWallAsync(photo, -1, progress, ct); Assert.That(info.Successful, Is.True); Assert.That(info.Photo?.Photo1280, Is.EqualTo(FakeResponsesForVkApi.ForPhotosSaveWallPhoto().Content[0]?.Photo1280)); //Assert.That(progressReportEverCalled, Is.True); //Assert.That(progressPercentage, Is.EqualTo(100)); }