コード例 #1
0
        public void GetUploadData_MissingFileName_Exception()
        {
            var imagekit = new ServerImagekit(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT)
                           .Tags("tag1");
            var ex = Assert.Throws <ArgumentException>(() => imagekit.getUploadData());

            Assert.Equal(errorMessages.MISSING_UPLOAD_FILENAME_PARAMETER, ex.Message);
        }
コード例 #2
0
        public void GetUploadData_TagsArray()
        {
            var fileName = Guid.NewGuid().ToString();
            var imagekit = new ServerImagekit(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT)
                           .FileName(fileName)
                           .Tags("tag1", "tag2");
            var data = imagekit.getUploadData();

            Assert.True(data.TryGetValue("tags", out string actualTags), "tags upload data not found");
            Assert.Equal("tag1,tag2", actualTags);
        }
コード例 #3
0
        public void GetUploadData_Generic()
        {
            var fileName = Guid.NewGuid().ToString();
            var imagekit = new ServerImagekit(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT)
                           .FileName(fileName)
                           .Folder("/test/")
                           .isPrivateFile(true)
                           .UseUniqueFileName(false)
                           .CustomCoordinates("10,10,100,100")
                           .ResponseFields("tags,customCoordinates,isPrivateFile")
                           .Tags("tag1,tag2");
            var data = imagekit.getUploadData();

            Assert.True(data.TryGetValue("responseFields", out string respFields), "ResponseFields upload data not found");
            Assert.True(data.TryGetValue("useUniqueFileName", out string uniqueParam), "UseUniqueFileName upload not found");
            Assert.True(data.TryGetValue("folder", out string folder), "folder upload not found");
            Assert.Equal("tags,customCoordinates,isPrivateFile", respFields);
            Assert.Equal("false", uniqueParam);
            Assert.Equal("/test/", folder);
        }