You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapHelps_Tests.cs

84 lines
2.0 KiB

using System.Collections.Generic;
using Shouldly;
using Xunit;
namespace Volo.Abp.Ldap
{
public class LdapHelps_Tests
{
[Fact]
public void BuildCondition_With_Value()
{
// act
var res = LdapHelps.BuildCondition("objectClass", "testNameA");
// assert
res.ShouldBe("(objectClass=testNameA)");
}
[Fact]
public void BuildCondition_With_Null_Value()
{
// act
var res = LdapHelps.BuildCondition("objectClass", null);
// assert
res.ShouldBeEmpty();
}
[Fact]
public void BuildCondition_With_Empty_Value()
{
// act
var res = LdapHelps.BuildCondition("objectClass", "");
// assert
res.ShouldBeEmpty();
}
[Fact]
public void BuildCondition_With_WhiteSpace_Value()
{
// act
var res = LdapHelps.BuildCondition("objectClass", " ");
// assert
res.ShouldBeEmpty();
}
[Fact]
public void BuildFilter_With_Null_Condition()
{
// act
var res = LdapHelps.BuildFilter(null);
// assert
res.ShouldBe("(&(objectClass=*))");
}
[Fact]
public void BuildFilter_With_Empty_Condition()
{
// act
var res = LdapHelps.BuildFilter(new Dictionary<string, string>());
// assert
res.ShouldBe("(&(objectClass=*))");
}
[Fact]
public void BuildFilter_With_Condition()
{
// act
var conditions = new Dictionary<string, string>
{
{"objectClass", "testClassA"}, {"objectCategory", "testCategoryA"}, {"name", null}
};
var res = LdapHelps.BuildFilter(conditions);
// assert
res.ShouldBe("(&(objectClass=testClassA)(objectCategory=testCategoryA))");
}
}
}