public void IsValidEmail() { var email = "*****@*****.**"; var emailRegex = new Regex(@"^[^@\s]+@[^@\s]+\.[^@\s]+$"); StringAssert.Matches(email, emailRegex); }
public void CustomerService() { var username = "******"; var password = "******"; _driver.Navigate().GoToUrl("http://automationpractice.com/index.php"); _driver.FindElement(By.ClassName("login")).Click(); var email = _driver.FindElement(By.Id("email")); email.SendKeys(username); var pass = _driver.FindElement(By.Id("passwd")); pass.SendKeys(password); _driver.FindElement(By.Id("SubmitLogin")).Click(); _driver.Navigate().GoToUrl("http://automationpractice.com/index.php?controller=contact"); var dropList = _driver.FindElement(By.Id("id_contact")); var clickThis = new SelectElement(dropList); clickThis.SelectByIndex(2); _driver.FindElement(By.Id("email")).SendKeys(username); _driver.FindElement(By.Id("id_order")).SendKeys("123212"); _driver.FindElement(By.Id("message")).SendKeys("Message"); _driver.FindElement(By.Id("submitMessage")).Click(); var waitForSubmitCreate = new WebDriverWait(_driver, TimeSpan.FromSeconds(10)); waitForSubmitCreate.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.UrlContains("controller=contact")); StringAssert.Contains("successfully sent", _driver.PageSource); }
public void VerifyForeignKeysExist_CodeExist_ReturnString() { // Arrange var blastId = 1; var blastGroupId = 1; var blastEngine = new ECNBlastEngine(); var exceptionMsg = "Code ID: "; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.HTML.ToString(); blast.CodeID = 1; return(blast); }; ShimGroup.GetByGroupID_NoAccessCheckInt32 = (id) => { var group = new Group(); return(group); }; ShimDataFunctions.GetDataTableSqlCommand = (cmd) => { return(new DataTable()); }; // Act var actualResult = typeof(ECNBlastEngine).CallMethod(METHOD_VerifyForeignKey, new object[] { blastId }, blastEngine).ToString(); // Assert StringAssert.Contains(actualResult, exceptionMsg); }
public void IsStringContainsSubstring() { var stringValue = "programming language"; var substring = "program"; StringAssert.Contains(stringValue, substring); }
public void VerifyForeignKeysExist_BlastGroupIsNull_ReturnString() { // Arrange var blastId = 1; var blastGroupId = 1; var blastEngine = new ECNBlastEngine(); var exceptionMsg = "Group ID: "; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.HTML.ToString(); return(blast); }; ShimGroup.GetByGroupID_NoAccessCheckInt32 = (id) => { return(null); }; // Act var actualResult = typeof(ECNBlastEngine).CallMethod(METHOD_VerifyForeignKey, new object[] { blastId }, blastEngine).ToString(); // Assert StringAssert.Contains(actualResult, exceptionMsg); }
public void VerifyForeignKeysExist_IsChampionSampleIDExist_ReturnString() { // Arrange var blastId = 1; var blastGroupId = 1; var blastEngine = new ECNBlastEngine(); var exceptionMsg = "Blast ID:"; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.Champion.ToString(); blast.LayoutID = 1; blast.SampleID = 1; return(blast); }; ShimGroup.GetByGroupID_NoAccessCheckInt32 = (id) => { var group = new Group(); return(group); }; ShimDataFunctions.GetDataTableSqlCommand = (cmd) => { return(new DataTable()); }; ShimLayout.GetByLayoutID_NoAccessCheckInt32Boolean = (id, child) => { var layout = new Layout(); layout.ContentSlot1 = 0; layout.TemplateID = 1; return(layout); }; ShimECNBlastEngine.AllInstances.ContentExistsInt32 = (eng, id) => { return("ContentExist"); }; ShimTemplate.GetByTemplateID_NoAccessCheckInt32 = (id) => { var template = new Template { TemplateSource = "TemplateSource", TemplateText = "TemplateText" }; return(template); }; ShimGroup.ValidateDynamicStringsForTemplateListOfStringInt32User = (list, groupId, user) => { }; // Act var actualResult = typeof(ECNBlastEngine).CallMethod(METHOD_VerifyForeignKey, new object[] { blastId }, blastEngine).ToString(); // Assert StringAssert.Contains(actualResult, exceptionMsg); }
public void VerifyForeignKeysExist_NotChampionLayoutExistContentSlot9Exists_ReturnString() { // Arrange var blastId = 1; var blastGroupId = 1; var blastEngine = new ECNBlastEngine(); var exceptionMsg = "ContentExist"; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.HTML.ToString(); blast.LayoutID = 1; return(blast); }; ShimGroup.GetByGroupID_NoAccessCheckInt32 = (id) => { var group = new Group(); return(group); }; ShimDataFunctions.GetDataTableSqlCommand = (cmd) => { return(new DataTable()); }; ShimLayout.GetByLayoutID_NoAccessCheckInt32Boolean = (id, child) => { var layout = new Layout(); layout.ContentSlot1 = 0; layout.ContentSlot9 = 1; return(layout); }; ShimECNBlastEngine.AllInstances.ContentExistsInt32 = (eng, id) => { if (id == 1) { return("ContentExist"); } return(""); }; // Act var actualResult = typeof(ECNBlastEngine).CallMethod(METHOD_VerifyForeignKey, new object[] { blastId }, blastEngine).ToString(); // Assert StringAssert.Contains(actualResult, exceptionMsg); }
public void ThenAllTheShownAnalysisShouldContainTheFollowingTags(string selectedTag) { BasePage.WaitForAjax(30, true); var actualTagsFromAnalysisAsList = CreateComparisonPage.ComparisonTagsList(); try { foreach ( var analysisTag in actualTagsFromAnalysisAsList.Select(tag => Regex.Replace(tag.Text, "\r\n?|\n", " "))) { StringAssert.Contains(analysisTag, selectedTag); } } catch (AssertFailedException e) { throw new AssertFailedException(e.Message); } }
public void StringDoesNotMatchRegexObject() { Regex pattern = new Regex("..."); string actualValue = "xxx"; // MSTest MSTestStringAssert.DoesNotMatch(actualValue, pattern, "Some context"); // StringAssert.DoesNotMatch failed. String 'xxx' matches pattern '...'. Some context. // NUnit does not support this case. // XUnit XUnitAssert.DoesNotMatch(pattern, actualValue); // Assert.DoesNotMatch() Failure: // Regex: ... // Value: xxx // Fluent does not support this case. // Shouldly does not support this case. }
public void RegistrationTest() { var guid = Guid.NewGuid(); var username = $"{guid.ToString()}@email.com"; var password = "******"; _driver.Navigate().GoToUrl("http://automationpractice.com/index.php"); _driver.FindElement(By.ClassName("login")).Click(); _driver.FindElement(By.Id("email_create")).SendKeys(username); _driver.FindElement(By.Id("SubmitCreate")).Click(); var waitForSubmitCreate = new WebDriverWait(_driver, TimeSpan.FromSeconds(10)); waitForSubmitCreate.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.UrlContains("my-account#account-creation")); _driver.FindElement(By.Id("id_gender2")).Click(); _driver.FindElement(By.Id("customer_firstname")).SendKeys("FirstName"); _driver.FindElement(By.Id("customer_lastname")).SendKeys("Lastname"); _driver.FindElement(By.Id("passwd")).SendKeys(password); _driver.FindElement(By.Id("address1")).SendKeys("TotallyAddress"); _driver.FindElement(By.Id("city")).SendKeys("MyCity"); var dropList = _driver.FindElement(By.Id("id_state")); var clickThis = new SelectElement(dropList); clickThis.SelectByIndex(1); _driver.FindElement(By.Id("postcode")).SendKeys("00000"); _driver.FindElement(By.Id("phone_mobile")).SendKeys("123123123"); _driver.FindElement(By.Id("submitAccount")).Click(); var waitForSubmit = new WebDriverWait(_driver, TimeSpan.FromSeconds(10)); waitForSubmit.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.ClassName("navigation_page"))); StringAssert.Contains(_driver.Url, "controller=my-account"); }
public void LoginTest() { var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10)); var username = "******"; var password = "******"; _driver.Navigate().GoToUrl("http://automationpractice.com/index.php"); _driver.FindElement(By.ClassName("login")).Click(); var email = _driver.FindElement(By.Id("email")); email.SendKeys(username); var pass = _driver.FindElement(By.Id("passwd")); pass.SendKeys(password); _driver.FindElement(By.Id("SubmitLogin")).Click(); wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.UrlContains("controller=my-account")); StringAssert.Contains(_driver.Url, "controller=my-account"); }
public void StringContains() { string expectedValue = "XXX"; string actualValue = "xxx"; // MSTest MSTestStringAssert.Contains(actualValue, expectedValue, "Some context"); // StringAssert.Contains failed. String 'xxx' does not contain string 'XXX'. Some context // NUnit Assert.That(actualValue, Does.Contain(expectedValue), () => "Some context"); // Some context // Expected: String containing "XXX" // But was: "xxx" // XUnit XUnitAssert.Contains(expectedValue, actualValue); // Assert.Contains() Failure // Not found: XXX // In value: xxx // Fluent actualValue.Should().Contain(expectedValue, "SOME REASONS"); // Expected actualValue "xxx" to contain "XXX" because SOME REASONS. // Shouldly actualValue.ShouldContain(expectedValue, "Some context", Case.Sensitive); // actualValue // should contain // "XXX" // but was actually // "xxx" // // Additional Info: // Some context }
public void StringEndsWith() { string expectedValue = "XX"; string actualValue = "xxx"; // MSTest MSTestStringAssert.EndsWith(actualValue, expectedValue, "Some context"); // StringAssert.EndsWith failed. String 'xxx' does not end with string 'XX'. Some context // NUnit Assert.That(actualValue, Does.EndWith(expectedValue), () => "Some context"); // Some context // Expected: String ending with "XX" // But was: "xxx" // XUnit XUnitAssert.EndsWith(expectedValue, actualValue); // Assert.EndsWith() Failure // Expected: XX // Actual: ***xx // Fluent actualValue.Should().EndWith(expectedValue, "SOME REASONS"); // Expected actualValue "xxx" to end with "XX" because SOME REASONS. // Shouldly actualValue.ShouldEndWith(expectedValue, "Some context", Case.Sensitive); // actualValue // should end with // "XX" // but was // "xxx" // // Additional Info: // Some context }
public void StringStartsWith() { string expectedValue = "XX"; string actualValue = "xxx"; // MSTest MSTestStringAssert.StartsWith(actualValue, expectedValue, "Some context"); // StringAssert.StartsWith failed. String 'xxx' does not start with string 'XX'. Some context // NUnit Assert.That(actualValue, Does.StartWith(expectedValue), () => "Some context"); // Some context // Expected: String starting with "XX" // But was: "xxx" // XUnit XUnitAssert.StartsWith(expectedValue, actualValue); // Assert.StartsWith() Failure // Not found: XX // In value: xx... // Fluent actualValue.Should().StartWith(expectedValue, "SOME REASONS"); // Expected actualValue to start with "XX" because SOME REASONS, but "xxx" differs near "xxx" (index 0). // Shouldly actualValue.ShouldStartWith(expectedValue, "Some context", Case.Sensitive); // actualValue // should start with // "XX" // but was // "xxx" // // Additional Info: // Some context }
public void VerifyForeignKeysExist_IsChampionSampleIDExistLayoutExistWithException_ReturnString() { // Arrange var blastId = 1; var blastGroupId = 1; var blastEngine = new ECNBlastEngine(); var exceptionMsg = "UDF(s): "; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.Champion.ToString(); blast.LayoutID = 1; blast.SampleID = 1; return(blast); }; ShimGroup.GetByGroupID_NoAccessCheckInt32 = (id) => { var group = new Group(); return(group); }; ShimDataFunctions.GetDataTableSqlCommand = (cmd) => { var table = new DataTable(); table.Columns.Add("LayoutID", typeof(string)); var row = table.NewRow(); row[0] = "1"; table.Rows.Add(row); var row2 = table.NewRow(); row2[0] = "1"; table.Rows.Add(row2); return(table); }; ShimLayout.GetByLayoutID_NoAccessCheckInt32Boolean = (id, child) => { var layout = new Layout(); layout.ContentSlot1 = 0; layout.TemplateID = 1; return(layout); }; ShimECNBlastEngine.AllInstances.ContentExistsInt32 = (eng, id) => { return("ContentExist"); }; ShimTemplate.GetByTemplateID_NoAccessCheckInt32 = (id) => { var template = new Template { TemplateSource = "TemplateSource", TemplateText = "TemplateText" }; return(template); }; ShimGroup.ValidateDynamicStringsForTemplateListOfStringInt32User = (list, groupId, user) => { throw new ECNException(new List <ECNError>() { new ECNError { ErrorMessage = "Exception from Template subject line. error text", } }); }; // Act var actualResult = typeof(ECNBlastEngine).CallMethod(METHOD_VerifyForeignKey, new object[] { blastId }, blastEngine).ToString(); // Assert StringAssert.Contains(actualResult, exceptionMsg); }