I have looked at a few posts such as this one but it doesn't answer my question.
Basically I have use LINQKIT to build an expression which looks like this:
public Expression<Func<uv_Manifest, bool>> CreateManifestFilters(ManifestFilterItem filterItem)
{
var predicate = PredicateBuilder.New<uv_Manifest>;
if(!string.IsNullorWhiteSpace(filterItem.CID)){
predicate = predicate.And(x => x.CID == filterItem.CID && x.CID != null);
}
return predicate;
}
And I have a unit tests which looks like this:
[TestMethod()]
public void CreateManifestFilters_FunctionHitWithCIDPopulated_ExpressionWillContainWhereOnCID()
{
var filterItem = new ManifestFilterItem("002");
var predicate = PredicateBuilder.New<uv_Manifest>.And(x => x.CID == filterItem.CID && x.CID != null);
var result = _iManifestManager.CreateManifestFilters(filterItem);
var manifest = new uv_Manifest();
Assert.AreEqual(predicate, result);
}
What I am trying to do is check that the expression is doing a where on the property CID. However I get this error when the test fails:
Assert.AreEqual failed. Expected: ((CompareString(x.CID, value(FSVendor_Refactored.Tests.ManifestFixture+_Closure$__11-0).$VB$Local_filterItem.CID, False) == 0) AndAlso (Convert(x.CID) != null))>. Actual: ((CompareString(x.CID, value(FSVendor_RefactoredRepository.ManifestManager+_Closure$__2-0).$VB$Local_filterItem.CID, False) == 0) AndAlso (Convert(x.CID) != null))>.
I think I understand why it's failing, both the unit tests and CreateManifestFilters function are in different projects. So I believe that this is causing the test to fail.
Anyone know how to check the expression to check if it's doing a where on the CID property?
EDIT: This is NOT a duplicate as the other answer does not use PredicateBuilder therefore the linked answer doesn't suit my requirements.