public void Find_finds_redirect(string storedUrl, string notFoundUrl) { var redirect = new CustomRedirect(storedUrl, DefaultNewUri.ToString()); _sut.Add(redirect); var actual = _sut.Find(notFoundUrl.ToUri()); Assert.Equal(redirect.NewUrl, actual.NewUrl); }
public void Find_finds_most_specific_redirect_when_not_found_url_starts_with_stored_url() { var collection = new CustomRedirectCollection { new CustomRedirect("/oldsegment1/", "/newsegment1/"), new CustomRedirect("/oldsegment1/oldsegment2/", "/newsegment1/newsegment2/"), }; var urlToFind = "/oldsegment1/oldsegment2/?test=q"; var expected = "/newsegment1/newsegment2/?test=q"; var actual = collection.Find(urlToFind.ToUri()); Assert.Equal(expected, actual.NewUrl); }
public void Find_does_not_add_slash_when_querystring_parameters() { var collection = new CustomRedirectCollection { new CustomRedirect("/content/file", "/legacy"), new CustomRedirect("/content/file/", "/legacy/") }; var urlToFind = "/content/file?doc=filename¶m2=value"; var expected = "/legacy?doc=filename¶m2=value"; var actual = collection.Find(urlToFind.ToUri()); Assert.Equal(expected, actual.NewUrl); }