Skip to content

Commit

Permalink
Merge pull request #94 from mohibsheth/master
Browse files Browse the repository at this point in the history
#80 - Implement support for Thumbnail upload
  • Loading branch information
mfilippov authored Aug 30, 2017
2 parents 39ce0a5 + 6aa62e0 commit 78684cb
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 195 deletions.
Binary file added src/VimeoDotNet.Tests/Resources/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 23 additions & 10 deletions src/VimeoDotNet.Tests/VimeoClientAsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public class VimeoClientAsyncTests

private const string Testtexttrackfilepath = @"VimeoDotNet.Tests.Resources.test.vtt";

private const string Textthumbnailfilepath = @"VimeoDotNet.Tests.Resources.test.png";

public VimeoClientAsyncTests()
{
// Load the settings from a file that is not under version control for security
// The settings loader will create this file in the bin/ folder if it doesn't exist
_vimeoSettings = SettingsLoader.LoadSettings();
_vimeoSettings = SettingsLoader.LoadSettings();
}

[Fact]
public async Task Integration_VimeoClient_GetReplaceVideoUploadTicket_CanGenerateStreamingTicket()
{
Expand Down Expand Up @@ -82,7 +84,7 @@ public async Task Integration_VimeoClient_UploadEntireFile_UploadsFile_ByStream(
{
long length;
IUploadRequest completedRequest;

using (var file = new BinaryContent(GetFileFromEmbeddedResources(Testfilepath), "video/mp4"))
{
length = file.Data.Length;
Expand Down Expand Up @@ -172,6 +174,17 @@ public async Task Integration_VimeoClient_UploadPullLink()
video.ShouldNotBeNull();
}

[Fact]
public async Task Integration_VimeoClient_UploadThumbnail()
{
var client = CreateAuthenticatedClient();
using (var file = new BinaryContent(GetFileFromEmbeddedResources(Textthumbnailfilepath), "image/png"))
{
var picture = await client.UploadThumbnailAsync(_vimeoSettings.VideoId, file);
picture.ShouldNotBeNull();
}
}

[Fact]
public async Task Integration_VimeoClient_DeleteVideo_DeletesVideo()
{
Expand Down Expand Up @@ -254,7 +267,7 @@ public async Task Integration_VimeoClient_UpdateAccountInformation_UpdatesCurren
{
final.name.ShouldBe(original.name);
}

if (string.IsNullOrEmpty(original.bio))
{
final.bio.ShouldBeNull();
Expand All @@ -263,11 +276,11 @@ public async Task Integration_VimeoClient_UpdateAccountInformation_UpdatesCurren
{
final.bio.ShouldBe(original.bio);
}

if (string.IsNullOrEmpty(original.location))
{
final.location.ShouldBeNull();
}
}
else
{
final.location.ShouldBe(original.location);
Expand All @@ -290,7 +303,7 @@ public async Task Integration_VimeoClient_GetUserInformation_RetrievesUserInfo()
public async Task Integration_VimeoClient_GetAccountVideos_RetrievesCurrentAccountVideos()
{
var client = CreateAuthenticatedClient();
var videos = await client.GetUserVideosAsync(_vimeoSettings.UserId);
var videos = await client.GetUserVideosAsync(_vimeoSettings.UserId);
videos.ShouldNotBeNull();
}

Expand Down Expand Up @@ -383,7 +396,7 @@ public async Task Integration_VimeoClient_AlbumVideoManagement()
public async Task Integration_VimeoClient_AlbumManagement()
{
var client = CreateAuthenticatedClient();

// create a new album...
const string originalName = "Unit Test Album";
const string originalDesc = "This album was created via an automated test, and should be deleted momentarily...";
Expand All @@ -402,7 +415,7 @@ public async Task Integration_VimeoClient_AlbumManagement()

newAlbum.description.ShouldBe(originalDesc);

// retrieve albums for the current user...there should be at least one now...
// retrieve albums for the current user...there should be at least one now...
var albums = await client.GetAlbumsAsync();

albums.total.ShouldBeGreaterThan(0);
Expand Down Expand Up @@ -443,7 +456,7 @@ public async Task Integration_VimeoClient_GetTextTracksAsync()

// act
var texttracks = await client.GetTextTracksAsync(_vimeoSettings.VideoId);

// assert
texttracks.ShouldNotBeNull();
}
Expand Down
4 changes: 3 additions & 1 deletion src/VimeoDotNet.Tests/VimeoDotNet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@
<ItemGroup>
<EmbeddedResource Include="Resources\test.mp4" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Resources\test.png" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/VimeoDotNet/Constants/Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ internal static class Endpoints
public const string TextTracks = "/videos/{clipId}/texttracks/";
public const string TextTrack = "/videos/{clipId}/texttracks/{trackId}";

public const string Pictures = "/videos/{clipId}/pictures";

public static string GetCurrentUserEndpoint(string endpoint)
{
return endpoint.Replace("users/{userId}", "me");
Expand Down
8 changes: 8 additions & 0 deletions src/VimeoDotNet/Models/Picture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@ public class Picture {
/// Sizes
/// </summary>
public List<Size> sizes { get; set; }
///
/// link
///
public string link { get; set; }
///
/// resource_key
///
public string resource_key { get; set; }
}
}
Loading

0 comments on commit 78684cb

Please sign in to comment.