public void ConditionalSelectorBuilderWontAllowWhensWithoutThens() { Assert.Throws <InvalidOperationException>(() => { ElementSelectors.IConditionalSelectorBuilder b = ElementSelectors.ConditionalBuilder(); b.When(x => x != null); b.Build(); }); }
public void ConditionalBuilder() { XmlElement control = doc.CreateElement(FOO); XmlElement test = doc.CreateElement(BAR); ElementSelectors.IConditionalSelectorBuilder builder = ElementSelectors.ConditionalBuilder() .WhenElementIsNamed(FOO).ThenUse(ElementSelectors.ByName); Assert.IsFalse(builder.Build()(control, test)); builder.ElseUse(ElementSelectors.Default); // not or-ed Assert.IsFalse(builder.Build()(control, test)); XmlElement control2 = doc.CreateElement("baz"); Assert.IsTrue(builder.Build()(control2, test)); }