public async Task NormalizeAsyncReturnsCorrectResult(NormalizationTestData data)
        {
            var sut = data.CreateNormalizer();

            var actualUrl = await sut.NormalizeAsync(data.OriginalUrl);

            Assert.AreEqual(data.ExpectedUrl, actualUrl);
        }
        public async Task NormalizeAsyncProvidesMessageToLoadingWrapper()
        {
            var data = NormalizationTestData.CreateShortened(
                "http://poeurl.com/0dE",
                "http://poeurl.com/redirect.php?url=0dE",
                Ascendant);
            var    sut     = data.CreateNormalizer();
            string?message = null;

            Task <HttpResponseMessage> LoadingWrapper(string msg, Task <HttpResponseMessage> task)
            {
                message = msg;
                return(task);
            }

            var actualUrl = await sut.NormalizeAsync(data.OriginalUrl, LoadingWrapper);

            Assert.AreEqual(data.ExpectedUrl, actualUrl);
            Assert.AreEqual("Resolving shortened tree address", message);
        }
        private static IEnumerable <NormalizationTestData> CreateTestData()
        {
            yield return(NormalizationTestData.CreateShortened(
                             "https://www.google.com/url?q=http://poeurl.com/xer&amp;sa=D&amp;ust=1456857460554000&amp;usg=AFQjCNH6POtjRXIVzd_kSRbH7sOVYuZW7A",
                             "http://poeurl.com/redirect.php?url=xer",
                             ResolvedObsoleteAssassin, ObsoleteAssassin));

            yield return(NormalizationTestData.CreateShortened(
                             "https://www.google.com/url?q=http://poeurl.com/xer",
                             "http://poeurl.com/redirect.php?url=xer",
                             ResolvedObsoleteAssassin, ObsoleteAssassin));

            yield return(NormalizationTestData.CreateShortened(
                             "goo.gl/44tsqv",
                             "https://goo.gl/44tsqv",
                             ResolvedObsoleteAssassin, ObsoleteAssassin));

            yield return(NormalizationTestData.CreateShortened(
                             "http://tinyurl.com/glcmaeo",
                             "https://tinyurl.com/glcmaeo",
                             Ascendant));

            yield return(NormalizationTestData.CreateShortened(
                             "http://poeurl.com/0dE",
                             "http://poeurl.com/redirect.php?url=0dE",
                             Ascendant));

            yield return(NormalizationTestData.CreateShortened(
                             "http://poeurl.com/redirect.php?url=0dE",
                             "http://poeurl.com/redirect.php?url=0dE",
                             Ascendant));

            yield return(NormalizationTestData.CreateShortened(
                             "www.poeurl.com/0dE",
                             "http://poeurl.com/redirect.php?url=0dE",
                             Ascendant));

            yield return(NormalizationTestData.CreateShortened(
                             "poeurl.com/0dE",
                             "http://poeurl.com/redirect.php?url=0dE",
                             Ascendant));

            yield return(NormalizationTestData.CreateTwiceShortened(
                             "https://goo.gl/kKjcuK",
                             "https://goo.gl/kKjcuK",
                             "poeurl.com/0dE",
                             "http://poeurl.com/redirect.php?url=0dE",
                             Ascendant));

            yield return(NormalizationTestData.CreateUnchanged(
                             RuOccultist));

            yield return(NormalizationTestData.Create(
                             "https://ru.pathofexile.com/passive-skill-tree/AAAABAMBAAFvDXwOSA-rD8QRDxEvEVARlhXXFe0WvxslHU8gbiL0JIsqCyo4LL8s4TW5Nj07DTt8PV9HBkkTSVFJsUuuTLNQMFJTVL1WY1b1XEBca13yX2pirGNDbAhsC2yMbRlwUnBWdZ51_X3jf8aESIRvhq6Hy4ngi3qOio_6kBuTH5MnlouXlZfQl_SaE52qoS-io6crpzSnm6xmrJi0DLTFtUi4yrk-vorBxcM6w23K088V0B_Q0NRC1bnXz9h22VvbbtvU2-ffiuL35ljpAuq662PsGO-I7-vw1fGK8uH2_PfX-Tc%3D",
                             RuOccultist));

            yield return(NormalizationTestData.CreateUnchanged(
                             "https://pathofexile.com/passive-skill-tree/AAAABAAAAA=="));

            yield return(NormalizationTestData.CreateUnchanged(
                             "http://unsupported.com"));
        }