public void ConditionalSelectorBuilderWontAllowMultipleDefaults() { Assert.Throws <InvalidOperationException>(() => { ElementSelectors.IConditionalSelectorBuilder b = ElementSelectors.ConditionalBuilder(); b.ElseUse(ElementSelectors.ByName); b.ElseUse(ElementSelectors.ByName); }); }
public void ConditionalSelectorBuilderWontAllowThenWithoutWhen() { Assert.Throws <InvalidOperationException>(() => { ElementSelectors.IConditionalSelectorBuilderThen t = (ElementSelectors.IConditionalSelectorBuilderThen)ElementSelectors.ConditionalBuilder(); t.ThenUse(ElementSelectors.ByName); }); }
public void ConditionalSelectorBuilderWontAllowMultipleWhensWithoutInterleavingThens() { Assert.Throws <InvalidOperationException>(() => { ElementSelectors.IConditionalSelectorBuilder b = ElementSelectors.ConditionalBuilder(); b.When(x => x != null); b.WhenElementIsNamed(new XmlQualifiedName("foo")); }); }
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)); }