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 FileUploadJsonResult ImportDeleted(HttpPostedFileBase txtFile) { CheckAccess(); var redirects = new CustomRedirectCollection(); using (var streamReader = new StreamReader(txtFile.InputStream)) { while (streamReader.Peek() >= 0) { var url = streamReader.ReadLine(); if (!string.IsNullOrEmpty(url)) { redirects.Add(new CustomRedirect { OldUrl = url, State = (int)DataStoreHandler.State.Deleted, }); } } } string message; if (redirects.Count() != 0) { CustomRedirectHandler.Current.SaveCustomRedirects(redirects); message = string.Format(LocalizationService.Current.GetString("/gadget/redirects/importdeletedsuccess"), redirects.Count()); } else { message = LocalizationService.Current.GetString("/gadget/redirects/importnone"); } return(new FileUploadJsonResult { Data = new { message = message } }); }