-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathCreateSlideshowMethodsTest.cs
More file actions
97 lines (85 loc) · 3.57 KB
/
CreateSlideshowMethodsTest.cs
File metadata and controls
97 lines (85 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System.Collections.Generic;
using CloudinaryDotNet.Actions;
using NUnit.Framework;
using SystemHttp = System.Net.Http;
namespace CloudinaryDotNet.Tests.UploadApi
{
public class CreateSlideshowMethodsTest
{
[Test]
public void TestCreateSlideshowFromManifestTransformation()
{
var cloudinary = new MockedCloudinaryUpload();
const string slideshowManifest = "w_352;h_240;du_5;fps_30;vars_(slides_((media_s64:aHR0cHM6Ly9y" +
"ZXMuY2xvdWRpbmFyeS5jb20vZGVtby9pbWFnZS91cGxvYWQvY291cGxl);(media_s64:aH" +
"R0cHM6Ly9yZXMuY2xvdWRpbmFyeS5jb20vZGVtby9pbWFnZS91cGxvYWQvc2FtcGxl)))";
var csParams = new CreateSlideshowParams
{
ManifestTransformation = new Transformation().CustomFunction(CustomFunction.Render(slideshowManifest)),
Tags = new List<string> {"tag1", "tag2", "tag3"},
Transformation = new Transformation().FetchFormat("auto").Quality("auto")
};
cloudinary.CreateSlideshow(csParams);
cloudinary.AssertHttpCall(SystemHttp.HttpMethod.Post, "video/create_slideshow");
foreach (var expected in new List<string>
{
$"fn_render:{slideshowManifest}",
"tag1",
"tag2",
"tag3",
"f_auto,q_auto"
})
{
StringAssert.Contains(expected, cloudinary.HttpRequestContent);
}
}
[Test]
public void TestCreateSlideshowFromManifestJson()
{
var cloudinary = new MockedCloudinaryUpload();
const string expectedManifestJson =
@"{""w"":848,""h"":480,""du"":6,""fps"":30,""vars"":{""sdur"":500,""tdur"":500,""slides"":"+
@"[{""media"":""i:protests9""},{""media"":""i:protests8""},{""media"":""i:protests7""},"+
@"{""media"":""i:protests6""},{""media"":""i:protests2""},{""media"":""i:protests1""}]}}";
const string notificationUrl = "https://example.com";
const string uploadPreset = "test_preset";
const string testId = "test_id";
var csParams = new CreateSlideshowParams
{
ManifestJson = new SlideshowManifest
{
Width = 848,
Height = 480,
Duration = 6,
Fps = 30,
Variables = new Slideshow
{
SlideDuration = 500,
TransitionDuration = 500,
Slides = new List<Slide>
{
new Slide("i:protests9"), new Slide("i:protests8"), new Slide("i:protests7"),
new Slide("i:protests6"), new Slide("i:protests2"), new Slide("i:protests1")
}
}
},
PublicId = testId,
NotificationUrl = notificationUrl,
UploadPreset = uploadPreset,
Overwrite = true
};
cloudinary.CreateSlideshow(csParams);
foreach (var expected in new List<string>
{
expectedManifestJson,
testId,
notificationUrl,
uploadPreset,
"1" // Overwrite
})
{
StringAssert.Contains(expected, cloudinary.HttpRequestContent);
}
}
}
}