public void TestGetUploadPreset()
        {
            var localCloudinaryMock = new MockedCloudinary("{eval: 'some value'}");

            var result = localCloudinaryMock.GetUploadPreset(apiTestPreset);

            localCloudinaryMock.AssertHttpCall(SystemHttp.HttpMethod.Get, $"{uploadPresetsRootUrl}/{apiTestPreset}");
            Assert.AreEqual("some value", result.Eval);
        }
        public void TestListUploadPresets()
        {
            var localCloudinaryMock = new MockedCloudinary("{presets: [{eval: 'some value'}]}");

            var result = localCloudinaryMock.ListUploadPresets();

            localCloudinaryMock.AssertHttpCall(SystemHttp.HttpMethod.Get, uploadPresetsRootUrl);
            Assert.AreEqual("some value", result.Presets.First().Eval);
        }
        /// <summary>
        /// <para>Asserts that a given HTTP call was sent with expected JSON content.</para>
        /// </summary>
        ///
        /// <para>Asserts that a metadata field has expected structure and property values.
        /// See <a href="https://cloudinary.com/documentation/admin_api#generic_structure_of_a_metadata_field">
        /// Generic structure of a metadata field in API reference.</a></para>
        /// <param name="mockedCloudinary">An instance of the <see cref="Cloudinary"/> class with mocked HttpClient.</param>
        /// <param name="type"> The type of value that can be assigned to the metadata field.</param>
        /// <param name="externalId">A unique identification string for the metadata field.</param>
        /// <param name="dataSourceEntry">(Optional) Data source for a given field.</param>
        private static void AssertEncodedRequestFields(MockedCloudinary mockedCloudinary, string type, string externalId,
                                                       EntryParams dataSourceEntry = null)
        {
            var requestJson = JToken.Parse(mockedCloudinary.HttpRequestContent);

            Assert.AreEqual(type, requestJson["type"].Value <string>());
            Assert.AreEqual(externalId, requestJson["label"].Value <string>());
            Assert.AreEqual(externalId, requestJson["external_id"].Value <string>());

            if (dataSourceEntry == null)
            {
                return;
            }

            var firstDataSource = requestJson["datasource"]["values"].First;

            Assert.AreEqual(dataSourceEntry.Value, firstDataSource["value"].Value <string>());
            Assert.AreEqual(dataSourceEntry.ExternalId, firstDataSource["external_id"].Value <string>());
        }
 public void SetUp()
 {
     mockedCloudinary = new MockedCloudinary();
 }