public void CallStrOp_ThrowsOnUnrecognized() { Expression <Func <TestLdapModel, bool> > expr = TestLdapModel => TestLdapModel.Email.LastIndexOf("asdf") > 1; Action lambda = () => FilterCompiler.Compile(expr); Assert.Throws <NotImplementedException>(lambda); }
public void And_GeneratesValidFilterString() { Expression <Func <TestLdapModel, bool> > expr = ((TestLdapModel u) => u.CommonName.StartsWith("one") && u.CommonName.EndsWith("two")); var actual = FilterCompiler.Compile(expr); Assert.Equal("(&(cn=one*)(cn=*two))", actual); }
public void SimpleComparisons_PutsMemberRefOnLeft() { Expression <Func <TestLdapModel, bool> > expr = (TestLdapModel u) => "something" == u.GivenName; var b = FilterCompiler.Compile(expr); var result = FilterCompiler.Compile(expr); Assert.Equal("(givenname=something)", result); }
public void CanCreateDnMatchRules() { Expression <Func <Entry, bool> > expr = e => e[Rule.DnWithData, true] == "something"; var result = Compiler.Compile(expr); Assert.Equal($"(:dn:{Rule.DnWithData.RuleCode}:=something)", result); }
public void Compiler_CanUseCustomBaseModel() { Expression <Func <CustomEntry, bool> > expr = e => e["mail"] == "*****@*****.**"; // No Exceptions implies it correctly used the custom entry type. var result = Compiler.Compile(expr); Assert.Equal("([email protected])", result); }
public void InlineConstant_CompilesToValue() { Expression <Func <TestLdapModel, bool> > expr = (TestLdapModel u) => u.SamAccountName == "something"; var result = FilterCompiler.Compile(expr); Assert.Equal("(samaccountname=something)", result); }
public void Parse_1960CanHandleWhitespace(string input, string expected) { var compiler = new LdapFilterCompiler(null, new CompilerOptions() { Target = RFCTarget.RFC1960 }); var expr = Parser.Parse <Entry>(input); var filter = compiler.Compile(expr); Assert.Equal(expected, filter); }
public void Compile_ValueWithGermanUmlauts() { Expression <Func <TestLdapModel, bool> > expr = e => e.DistinguishedName == "CN=Domänen-Admins,CN=Users,DC=domain,DC=de"; var filter = FilterCompiler.Compile(expr); Assert.Equal(@"(distinguishedName=CN=Dom\c3\a4nen-Admins,CN=Users,DC=domain,DC=de)", filter); }