Esempio n. 1
0
        public async Task Get_Datatable_From_AzureFiles()
        {
            var dataTableName = "datatable";
            var result        = await CommonOperations.ConfigureTableAsync(connectionString);

            Assert.Equal(dataTableName, result.Name);
        }
Esempio n. 2
0
        /// <summary>
        /// Read the Azure Table and get the short URL for a given long URL
        /// </summary>
        /// <returns>Deshorten Long URL</returns>
        public async Task <string> DeshortenUrlFromAzureTable()
        {
            var dataTable = await CommonOperations.ConfigureTableAsync(this.ConnectionString);

            var ops = DataUtils.RetrieveEntityUsingPartitionKey(dataTable, this.Url);

            return(ops.RowKey);
        }
Esempio n. 3
0
        /// <summary>
        /// To short a given URL and save it to the Azure Table
        /// </summary>
        /// <returns>Shorten URL</returns>
        public async Task <string> ShortenUrlAndSaveToAzureTable()
        {
            // 8 character long short url is generated
            string shortUrl  = SubjectUrlUtil.GetShortUrl(8);
            var    dataTable = await CommonOperations.ConfigureTableAsync(this.ConnectionString);

            var ops = await DataUtils.InsertOrMergeEntityAsync(dataTable, new UrlEntity { PartitionKey = shortUrl, RowKey = this.Url });

            return(ops.PartitionKey);
        }