Exemplo n.º 1
0
        public async Task UpdateFileDetailsAsync_TagsArray(string[] tags, bool isValid)
        {
            var fileId   = Guid.NewGuid().ToString();
            var fileName = Guid.NewGuid().ToString();
            var imagekit = new ServerImagekit(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT)
                           .FileName(fileName)
                           .Tags(tags);

            if (isValid)
            {
                var responseObj = TestHelpers.ListAPIResponseFaker.Generate();
                responseObj.Tags = tags;
                responseObj.CustomCoordinates = null;
                var httpResponse = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = new StringContent(JsonConvert.SerializeObject(responseObj))
                };
                var httpClient = TestHelpers.GetTestHttpClient(httpResponse,
                                                               TestHelpers.GetUpdateFileDetailsMessageValidator(responseObj.Tags, null));
                Util.Utils.SetHttpClient(httpClient);

                var response = await imagekit.UpdateFileDetailsAsync(fileId);

                Assert.Equal(JsonConvert.SerializeObject(responseObj), JsonConvert.SerializeObject(response));
            }
            else
            {
                var ex = await Assert.ThrowsAsync <ArgumentException>(() => imagekit.UpdateFileDetailsAsync(fileId));

                Assert.Equal(Util.errorMessages.UPDATE_DATA_TAGS_INVALID, ex.Message);
            }
        }
Exemplo n.º 2
0
        public async Task UpdateFileDetailsAsync_TagsString(string tags)
        {
            var fileId      = Guid.NewGuid().ToString();
            var fileName    = Guid.NewGuid().ToString();
            var responseObj = TestHelpers.ListAPIResponseFaker.Generate();

            responseObj.Tags = tags == null ? null : tags.Split(",");
            if (responseObj.Tags != null && responseObj.Tags[0] == "null")
            {
                responseObj.Tags = null;
            }
            responseObj.CustomCoordinates = null;
            var httpResponse = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(responseObj))
            };
            var httpClient = TestHelpers.GetTestHttpClient(httpResponse,
                                                           TestHelpers.GetUpdateFileDetailsMessageValidator(responseObj.Tags, null));

            Util.Utils.SetHttpClient(httpClient);

            var imagekit = new ServerImagekit(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT)
                           .FileName(fileName)
                           .Tags(tags);
            var response = await imagekit.UpdateFileDetailsAsync(fileId);

            Assert.Equal(JsonConvert.SerializeObject(responseObj), JsonConvert.SerializeObject(response));
        }