public void SendWithExclusion() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; var inforoomRegion = TestRegion.Find(TestRegion.Inforoom); SetUp( new List <TestUser> { user }, inforoomRegion, "Это письмо пользователю", "Это текст письма пользователю", null); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass); handler.TestProcessMime(_info.Mime); var existsMessages = ImapHelper.CheckImapFolder(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass, ImapHelper.INBOXFolder); Assert.That(existsMessages.Count, Is.GreaterThanOrEqualTo(1), "Не найдены письма в IMAP-папке"); var responseCount = existsMessages .Count(m => m.Envelope?.Subject?.Equals(_responseSubject, StringComparison.CurrentCultureIgnoreCase) == true); Assert.That(responseCount, Is.EqualTo(1), "Не найдено письмо с загловком '{0}'", _responseSubject); var mails = TestMailSendLog.Queryable.Where(l => l.User.Id == user.Id).ToList(); Assert.That(mails.Count, Is.EqualTo(1)); var mailLog = mails[0]; Assert.That(mailLog.Mail.Supplier.Id, Is.EqualTo(_info.Supplier.Id)); }
public void AccessingTestRegions() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // The TestPage has 5 TestRegions defined on it. They all can be accessed // using the DomTree.Regions collection which contains a flat list of // all regions regardless of their nesting in the markup. Assert.IsTrue(ActiveBrowser.Regions.Count == 5); // Access the MainTable test region. TestRegion mainTable = ActiveBrowser.Regions["MainTable"]; Assert.IsTrue(mainTable.Id.Equals("MainTable")); // Access the programs table header. TestRegion programsTableHeader = ActiveBrowser.Regions["ProgramsTableHead"]; // Or - You can walk down the hierarchy of test regions. // // Note: The only reason you might want to do that is to validate a certain // high-level structure of your page as part of your testing // to make sure that all main parts are correctly positioned programsTableHeader = mainTable.ChildRegions["ProgramsTable"].ChildRegions["ProgramsTableHead"]; // TestRegion.ChildRegions contains only the immediate child // TestRegions where AllChildRegions contains all sub TestRegions // regardless of their nesting even within other sub TestRegions. Assert.IsTrue(mainTable.ChildRegions.Count == 1); Assert.IsTrue(mainTable.AllChildRegions.Count == 4); }
private void SetUp(IList <TestUser> users, TestRegion region, string subject, string body, IList <string> fileNames) { var info = new DocSourceHandlerTestInfo(); var supplier = TestSupplier.CreateNaked(session); var from = String.Format("{0}@supplier.test", supplier.Id); PrepareSupplier(supplier, from); info.Supplier = supplier; var toList = users.Select(u => "{0}@docs.analit.net".Format(u.AvaliableAddresses[0].Id)).ToList(); if (region != null) { toList.Add(region.ShortAliase + "@docs.analit.net"); } var message = ImapHelper.BuildMessageWithAttachments( subject, body, toList.ToArray(), new[] { from }, fileNames != null ? fileNames.ToArray() : null); info.Mime = message; info.Region = region; info.Users = users; _info = info; }
public void CheckRegionMask() { var regions = TestRegion.FindAll().ToList(); var vrnRegion = regions.Find(r => r.ShortAliase == "vrn"); var orelRegion = regions.Find(r => r.ShortAliase == "orel"); var client = TestClient.CreateNaked(vrnRegion.Id, vrnRegion.Id); var user = client.Users[0]; Assert.That(user.WorkRegionMask, Is.EqualTo(vrnRegion.Id), "У пользователя должен быть доступен только регион {0}", vrnRegion.Name); //к пользователю добаляем еще один регион в маску user.WorkRegionMask = user.WorkRegionMask | orelRegion.Id; var foundCause = String.Format("Пользователь {0} должен быть найден, т.к. маска клиента содержит регион {1} ({2})", user.Id, vrnRegion.Name, vrnRegion.Id); var notFoundCause = String.Format("Пользователь {0} не должен быть найден, т.к. маска клиента не должна содержать регион {1} ({2})", user.Id, orelRegion.Name, orelRegion.Id); CheckRegionMaskByRecipient(orelRegion.ShortAliase + "@docs.analit.net", RecipientType.Region, orelRegion, user, Is.Null, notFoundCause); CheckRegionMaskByRecipient(vrnRegion.ShortAliase + "@docs.analit.net", RecipientType.Region, vrnRegion, user, Is.Not.Null, foundCause); var address = client.Addresses[0]; CheckRegionMaskByRecipient(address.Id + "@docs.analit.net", RecipientType.Address, vrnRegion, user, Is.Not.Null, foundCause); CheckRegionMaskByRecipient(address.Id + "@docs.analit.net", RecipientType.Address, orelRegion, user, Is.Null, notFoundCause); CheckRegionMaskByRecipient(client.Id + "@client.docs.analit.net", RecipientType.Client, vrnRegion, user, Is.Not.Null, foundCause); CheckRegionMaskByRecipient(client.Id + "@client.docs.analit.net", RecipientType.Client, orelRegion, user, Is.Null, notFoundCause); }
public void FindElementsByID() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Set the short-cuts to the main automation objects. Browser brwser = Manager.ActiveBrowser; Find rootFind = brwser.Find; // All the testregion are initialized here. TestRegion r1 = brwser.Regions["Region1"]; TestRegion r11 = brwser.Regions["Region11"]; TestRegion r111 = brwser.Regions["Region111"]; TestRegion r1111 = brwser.Regions["Region1111"]; TestRegion r112 = brwser.Regions["Region112"]; //*** Using identification by id. Element div0 = r1.Find.ById("div0"); //*** Using tag name occurrence index. Element div = r1.Find.ByTagIndex("div", 0); Element div1 = r112.Find.ByTagIndex("div", 0); // Some verification to illustrate how the same element that was found // using TestRegion Find objects above, can be also found // using the main Browser Find object. Assert.IsTrue(div.Equals(rootFind.ByTagIndex("div", 0))); Assert.IsTrue(div0.Equals(rootFind.ByTagIndex("div", 1))); //*** Using attribute identification. Assert.IsTrue(div1.Equals(rootFind.ByAttributes("id=div1"))); Assert.IsNull(rootFind.ByAttributes("id=bla")); Assert.IsNotNull(rootFind.ByAttributes("href=http://www.kayak.com")); //*** Using partial attribute identification. Assert.IsTrue(rootFind.ByAttributes("bla=~__").Equals(rootFind.ById("div7"))); Assert.IsNull(rootFind.ByAttributes("id=~div7", "bla=~wow")); Assert.IsNotNull(rootFind.ByAttributes("onclick=~clicked();", "id=~button2")); //*** Using 'All' elements identification. // Note here that the first 'div' does not have any id that contains 'div' hence the '- 1'. Assert.AreEqual(rootFind.AllByTagName("div").Count - 1, rootFind.AllByXPath("/descendant::node()[starts-with(@id,'div')]").Count); Assert.AreEqual(5, rootFind.AllByAttributes("href=http://www.kayak.com").Count); Assert.AreEqual(2, rootFind.AllByAttributes("id=~button").Count); Assert.AreEqual(10, r1.Find.AllByTagName("div").Count); Assert.AreEqual(0, r1111.Find.AllByTagName("div").Count); Assert.AreEqual(2, r111.Find.AllByTagName("a").Count); Assert.AreEqual(9, r11.Find.AllByAttributes("id=~div").Count); //*** Using NodeIndexPath identification. Assert.IsTrue(r1.Find.ByNodeIndexPath("0/1/1").IdAttributeValue.Equals("input1")); Assert.IsTrue(rootFind.ByNodeIndexPath("1/0/0").TagName.Equals("div", StringComparison.OrdinalIgnoreCase)); //*** Using name Assert.IsNull(r1.Find.ByName("bla")); }
public static FocusArea Create() { //var testRegion = Region.CreateNewBlank(); var testRegion = TestRegion.Create(); var focusArea = FocusArea.CreateNewBlank(FocusAreaStatus.InProgress, testRegion); focusArea.FocusAreaName = MakeTestName("Test Focus Area"); focusArea.DNRUplandRegion.DNRUplandRegionName = MakeTestName("Test Region Name", 100); return(focusArea); }
public void AccessingElementsUsingTestRegions() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Each TestRegion object has a Find object associated with it that // performs the search within the elements contained in that region ONLY. // Any element search that requires indexing will be performed with // the <testregion> tag of that region as the root element to start // the indexing from. Below are examples to illustrate that. // MainTable region contains the table id="maintable1" but other // regions don't contain it. TestRegion MainTableRegion = ActiveBrowser.Regions["MainTable"]; TestRegion ProgramsTableRegion = ActiveBrowser.Regions["ProgramsTable"]; // // Scoping Search To TestRegion: // Assert.IsNotNull(MainTableRegion.Find.ById("maintable1")); Assert.IsNull(ProgramsTableRegion.Find.ById("maintable1")); // // Scoping Indexing To TestRegion : // // Let's find the ProgramsTable using tag index. // // // A) Common search without TestRegions // [We usually index the tag name from the root of the page which in this // case is '1' - the second occurrence of the tag 'table'] Element secondTableWithoutTR = Find.ByTagIndex("table", 1); // B) Using TestRegions // [We only need to index from the beginning of the TestRegion we are accessing] Element secondTableWithTR = ProgramsTableRegion.Find.ByTagIndex("table", 0); Assert.IsTrue(secondTableWithoutTR.Equals(secondTableWithTR)); // Note: // // With B) we don't care how the page changes outside the testregion // this test is targetting. This means that we can literally take // that TestRegion and paste it in another page and the test should // work. In contrast with A) the test is more vulnerable to changes. For // example, if another table is added before ProgramsTable, the test // will break where B won't. // // For highly dynamic sites or sites in early development with // lots of churn, it is recommended to use TestRegions to limit // the cost of maintaining tests. }
public void CheckExistsRegion() { var region = TestRegion.Find(1ul); var recipient = MailRecipient.Parse(region.ShortAliase + "@docs.analit.net"); Assert.That(recipient, Is.Not.Null); Assert.That(recipient.Email, Is.EqualTo(region.ShortAliase + "@docs.analit.net")); Assert.That(recipient.Type, Is.EqualTo(RecipientType.Region)); Assert.That(recipient.Address, Is.Null); Assert.That(recipient.Region, Is.Not.Null); Assert.That(recipient.Client, Is.Null); Assert.That(recipient.Region.Id, Is.EqualTo(region.Id)); Assert.That(recipient.Status, Is.EqualTo(RecipientStatus.Verified)); }
public void UsingFindExpressionAttributeWithTestRegions() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // FindExpression attributes can be associated to a specific TestRegion. // When a TestRegionId is specified, only the Find object off that region // object can be used to access that element. The search will be scoped // to that region also. // Two FindExpression attribues are defined on this method. Both point to the // same element on the page. // The first is generic can be accessed using the ActiveBrowser.Find object. // The second can be accessed only using the ProgramsTable.Find object. TestRegion ProgramsTable = ActiveBrowser.Regions["ProgramsTable"]; // Contains only the element defined and scoped to "ProgramsTable"; Assert.IsTrue(this.Elements.GetHtml("progtbl").Equals(this.Elements.GetHtml("progtbltr"))); // Note: You can also use the FindAttribute(fileName) and scope all // the elements contained in file to a specific testregion. }
private void CheckRegionMaskByRecipient(string address, RecipientType recipientType, TestRegion region, TestUser user, NullConstraint constraint, string causeMessage) { var recipient = MailRecipient.Parse(address); Assert.That(recipient, Is.Not.Null); Assert.That(recipient.Type, Is.EqualTo(recipientType)); Assert.That(recipient.Status, Is.EqualTo(RecipientStatus.Verified)); var recipientUsers = recipient.GetUsers(region.Id); var findedUser = recipientUsers.FirstOrDefault(u => u.Id == user.Id); Assert.That(findedUser, constraint, causeMessage); }