public void IsValidShouldReturnFalseWhenTheSpecifiedValueIsNotString() { UrlValidator urlValidator = new UrlValidator(); Assert.AreEqual(false, urlValidator.IsValid(100)); Assert.AreEqual(false, urlValidator.IsValid(new object())); }
public void ValidationFailsForInvalidUrls() { UrlValidator validator = new UrlValidator(); Assert.IsFalse(validator.IsValid(this, "http://www")); Assert.IsFalse(validator.IsValid(this, ".www.bbc.co.uk")); Assert.IsFalse(validator.IsValid(this, "ftp:///my.ftp.site")); }
public void ValidationPassesForValidUrls() { UrlValidator validator = new UrlValidator(); Assert.IsTrue(validator.IsValid(this, "http://www.castleproject.org")); Assert.IsTrue(validator.IsValid(this, "http://www.bbc.co.uk")); Assert.IsTrue(validator.IsValid(this, "ftp://my.ftp.site")); Assert.IsTrue(validator.IsValid(this, "http://www.tickets.com/file.extension?id=something")); }
public void IsValid_ActionExecutes_TrueOrFalse(string input, bool expected) { var validator = new UrlValidator(); var result = validator.IsValid(input); Assert.Equal(expected, result); }
public void AssertInvalidUrls( [Values( "google.com", "www.google.com", "google", "http://google", "amqp://google.com")] string url) { UrlValidator urlValidator = new UrlValidator(); Assert.AreEqual(false, urlValidator.IsValid(url), string.Format(CultureInfo.CurrentCulture, "The url '{0}' should be invalid", url)); }
public ActionResult UrlShortener([FromBody] UrlShortenerRequest request) { if (!UrlValidator.IsValid(request.Url)) { return(BadRequest("Not a valid URL")); } var id = GenerateShortUrl(); var shortUrlDetails = new ShortUrlDetail { Id = id, OriginalUrl = request.Url, ShortUrl = $"https://localhost:5001/{id}" }; _DB.Add(shortUrlDetails); return(Ok(shortUrlDetails)); }
public void IsValidTest() { var validator = new UrlValidator(); Assert.IsFalse(validator.IsValid("htp://google.com")); Assert.IsFalse(validator.IsValid("www.google.com")); Assert.IsFalse(validator.IsValid("bing.com")); Assert.IsTrue(validator.IsValid("http://www.bing.com")); Assert.IsTrue(validator.IsValid("https://duckduckgo.com/")); Assert.IsTrue(validator.IsValid("https://abc.xyz/")); }
private void MenuGenerateReport_Click(object sender, RoutedEventArgs e) { // TODO same as analyzeButton_Click ^ var urlValidator = new UrlValidator(); if (urlValidator.IsValid(UrlTextBox.Text)) { var analyzer = new Analyzer(UrlTextBox.Text, KeywordTextBox.Text); analyzer.Analyze(); ReportsGenerator.GenerateReport(analyzer); } else { MessageBox.Show(this, "Please enter valid url/keyword!", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void analyzeButton_Click(object sender, RoutedEventArgs e) { // TODO make a function using the code below var urlValidator = new UrlValidator(); if (urlValidator.IsValid(UrlTextBox.Text)) { var analyzer = new Analyzer(UrlTextBox.Text, KeywordTextBox.Text); analyzer.Analyze(); ReportsGenerator.GenerateReport(analyzer, ref ReportDataGrid); } else { MessageBox.Show(this, "Please enter valid url/keyword!", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void AssertValidUrls( [Values( "http://google.com", "http://apps.google.com", "http://www.google.com", "http://ms1.apps.google.com", "https://google.com", "https://apps.google.com", "https://www.google.com", "https://ms1.apps.google.com", "ftp://google.com", "ftp://ftp.google.com", "http://google.it")] string url) { UrlValidator urlValidator = new UrlValidator(); Assert.AreEqual(true, urlValidator.IsValid(url), string.Format(CultureInfo.CurrentCulture, "The url '{0}' should be valid", url)); }
private void goButton_Click(object sender, EventArgs e) { bottomStatusLabel.Text = ""; // FIND THE EMPTY FIELDS: List <string> empties = new List <string>(); foreach (Control c in this.Controls) { if (c is TextBox) { TextBox textBox = c as TextBox; if (textBox.Text == string.Empty) { empties.Add(textBox.Name.ToString()); } } else if (c is ComboBox) { ComboBox comboBox = c as ComboBox; if (comboBox.Text == string.Empty) { empties.Add(comboBox.Name.ToString()); } } } //foreach (var item in empties) // Console.Write(item + ", "); if (browserComboBox.Text == string.Empty || urlTextBox.Text == string.Empty || usernameBox.Text == string.Empty || passwordBox.Text == string.Empty) { SetBottomStatus("Missing information. Please insert all information."); } else if (UrlValidator.IsValid(urlTextBox.Text)) { // Hent browser, url, brukernavn og passord: browser = browserComboBox.Text; confluenceurl = urlTextBox.Text; username = usernameBox.Text; password = passwordBox.Text; if (browser.Contains("Opera")) { SetBottomStatus("Opera is not yet supported. Please select a different browser."); } else if (browser.Contains("FIREFOX")) { SetBottomStatus("Firefox is not yet supported. Please select a different browser."); } else if (browser.Contains("IEXPLORE")) { SetBottomStatus("Internet Explorer is not yet supported. Please select a different browser."); } else if (browser.Contains("Chrome")) { // KJØR SELENIUM! SetBottomStatus("Klar"); Selenium.GCDriver.Initialize(); site.GoTo(confluenceurl); site.LogIn(username, password); site.GetSpaces(); site.Close(); } } else { SetBottomStatus("Invalid or malformed URL.Please enter a valid URL."); } }
public void IsValidShouldReturnTrueWhenTheSpecifiedValueIsNull() { UrlValidator urlValidator = new UrlValidator(); Assert.AreEqual(true, urlValidator.IsValid(null)); }