private void AssertCandidateMenu(int?credits, PhoneNumberVisibility visibility) { var node = Browser.CurrentHtml.DocumentNode.SelectSingleNode("//tr[@class='action-items' and position()=2]/td[position()=1]/div"); Assert.IsNotNull(node); Assert.AreEqual("View phone numbers", node.InnerText); switch (visibility) { case PhoneNumberVisibility.Available: if (credits == null) { Assert.AreEqual("view-phone-numbers js_action-item action-item", node.Attributes["class"].Value); } else if (credits.Value == 0) { Assert.AreEqual("view-phone-numbers-disabled js_action-item action-item", node.Attributes["class"].Value); } else { Assert.AreEqual("view-phone-numbers-locked js_action-item action-item", node.Attributes["class"].Value); } break; case PhoneNumberVisibility.NotSupplied: Assert.AreEqual("view-phone-numbers-disabled js_action-item action-item", node.Attributes["class"].Value); break; case PhoneNumberVisibility.Shown: Assert.AreEqual("view-phone-numbers-disabled js_action-item action-item", node.Attributes["class"].Value); break; } }
protected abstract void TestPhoneNumbers(Member member, int?credits, bool unlocked, PhoneNumberVisibility visibility);
private void TestPhoneNumbers(bool anonymous, int?credits, bool unlocked, bool phoneNumbers, bool hidden, PhoneNumberVisibility visibility) { var employer = anonymous ? null : CreateEmployer(credits); var member = CreateMember(phoneNumbers, hidden); if (unlocked) { Contact(employer, member); } // Search. if (employer != null) { LogIn(employer); } // Test. TestPhoneNumbers(member, credits, unlocked, visibility); }
private void AssertExpandedPhoneNumbers(IHavePhoneNumbers member, bool unlocked, PhoneNumberVisibility visibility) { var node = Browser.CurrentHtml.DocumentNode.SelectSingleNode("//ul[@class='unlocking-and-phones']"); Assert.IsNotNull(node); // Unlocked node. var unlockedNode = node.SelectSingleNode("li/span[@class='contact-unlocked-icon']"); if (unlocked) { Assert.IsNotNull(unlockedNode); Assert.AreEqual("", unlockedNode.InnerText); } else { Assert.IsNull(unlockedNode); } // Locked node. var lockedNode = node.SelectSingleNode("li/a[@class='contact-locked-icon']"); if (unlocked) { Assert.IsNull(lockedNode); } else { Assert.IsNotNull(lockedNode); Assert.AreEqual("", lockedNode.InnerText); } // Mobile node. var mobileNode = node.SelectSingleNode("li/span[@class='phone-mobile-icon phone-number']"); var mobileDimmedNode = node.SelectSingleNode("li/span[@class='phone-mobile-dimmed-icon']"); var notSuppliedNode = node.SelectSingleNode("li/span[@class='emptynumber']"); var mobilePhoneNumber = member.PhoneNumbers == null ? null : (from p in member.PhoneNumbers where p.Type == PhoneNumberType.Mobile select p).Single().Number; switch (visibility) { case PhoneNumberVisibility.Shown: Assert.IsNotNull(mobileNode); Assert.AreEqual(mobilePhoneNumber, mobileNode.InnerText); Assert.IsNull(mobileDimmedNode); Assert.IsNull(notSuppliedNode); break; case PhoneNumberVisibility.Available: Assert.IsNull(mobileNode); Assert.IsNotNull(mobileDimmedNode); Assert.AreEqual("Available", mobileDimmedNode.InnerText); AssertPageDoesNotContain(mobilePhoneNumber); Assert.IsNull(notSuppliedNode); break; default: Assert.IsNull(mobileNode); Assert.IsNull(mobileDimmedNode); if (mobilePhoneNumber != null) { AssertPageDoesNotContain(mobilePhoneNumber); } Assert.IsNotNull(notSuppliedNode); break; } }
protected override void TestPhoneNumbers(Member member, int?credits, bool unlocked, PhoneNumberVisibility visibility) { var criteria = new MemberSearchCriteria(); criteria.SetKeywords(BusinessAnalyst); Get(GetPartialSearchUrl(criteria, DetailLevel.Expanded)); AssertExpandedPhoneNumbers(member, unlocked, visibility); }
protected override void TestPhoneNumbers(Member member, int?credits, bool unlocked, PhoneNumberVisibility visibility) { Get(GetCandidatesUrl(member.Id)); AssertCandidatePhoneNumbers(member, unlocked, visibility); AssertCandidateMenu(credits, visibility); }