Exemplo n.º 1
0
        public async Task Short_Url_Command_Returns_Not_Null()
        {
            SubjectUrlForAzureTable url = new SubjectUrlForAzureTable("https://www.microsoft.com/en-my/", connectionString);
            ICommand command            = new ShortUrlAzureTableCommand(url, UrlAction.Short);
            var      result             = await command.ExecuteAction();

            Assert.NotNull(result);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ShortUrl([FromBody] SubjectUrl subjectUrl)
        {
            SubjectUrlForAzureTable url = new SubjectUrlForAzureTable(subjectUrl.Url, connectionString);

            ICommand doShort    = new ShortUrlAzureTableCommand(url, UrlAction.Short);
            string   shortenUrl = await doShort.ExecuteAction();

            return(Ok(shortenUrl));
        }
Exemplo n.º 3
0
        public async Task Deshort_Url_Command_Gives_Correct_Value()
        {
            var givenUrl                = "MccLSngp";
            var expectedUrl             = "https://www.microsoft.com/en-my/";
            SubjectUrlForAzureTable url = new SubjectUrlForAzureTable(givenUrl, connectionString);
            ICommand command            = new ShortUrlAzureTableCommand(url, UrlAction.Deshort);
            var      result             = await command.ExecuteAction();

            Assert.Equal(result, expectedUrl);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetAndRedirectToLongUrl(string shortUrl)
        {
            SubjectUrlForAzureTable url = new SubjectUrlForAzureTable(shortUrl, connectionString);

            ICommand doDeshort    = new ShortUrlAzureTableCommand(url, UrlAction.Deshort);
            string   deshortenUrl = await doDeshort.ExecuteAction();


            return(Redirect(deshortenUrl));
        }