Exemplo n.º 1
0
        static void Main(string[] args)
        {
            AlphabetEncoder encoder = AlphabetEncoder.B62Encoder();

            string longurl = "http://www.youtube.com/sdfiouwensdifo?start=10";

            string shortUrl = encoder.Encode(1);

            Console.WriteLine($"Long url: {longurl}");
            Console.WriteLine($"Encoded Short URL: {shortUrl}");

            long recalculatedId = encoder.Decode(shortUrl);

            Console.WriteLine($"Recalculated Id: {recalculatedId}");

            string connectionString = "Server=tcp:urlshortnersqlserver.database.windows.net,1433;Initial Catalog=UrlShortnerDb;Persist Security Info=False;User ID=nate;Password=214Mercedes!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

            var optionsBuilder = new DbContextOptionsBuilder();// <UrlShortnerDbContext>();

            optionsBuilder.UseSqlServer(connectionString);

            using (UrlShortnerDbContext context = new UrlShortnerDbContext(optionsBuilder.Options))
            {
                var service = new ShortenedUrlsService(context);

                Console.WriteLine(service.GetById(1).Result);
            }
        }
Exemplo n.º 2
0
        public void Decode_ReturnsCorrectBigInteger_WhenPassedASingleCharacter(string input, ulong expected)
        {
            BigInteger result = _sut.Decode(input);

            Assert.Equal(expected, result);
        }