Skip to content

Commit

Permalink
Fix to join predicates in Mocking adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
markrendle committed Mar 7, 2011
1 parent 5e1f0bf commit 2db1dc1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CommonAssemblyInfo.cs
Expand Up @@ -19,5 +19,5 @@
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

[assembly: AssemblyVersion("0.5.1.0")]
[assembly: AssemblyFileVersion("0.5.1.0")]
[assembly: AssemblyVersion("0.5.1.1")]
[assembly: AssemblyFileVersion("0.5.1.1")]
19 changes: 19 additions & 0 deletions Simple.Data.Mocking.Test/XmlMockAdapterTest.cs
Expand Up @@ -196,6 +196,25 @@ public void FindBy_WithNonMatchingSecondValue_ShouldNotFind()
var customer = db.CustomerData.FindByCustomerNoAndAccountManagerEmail(1, "someEmail");
Assert.IsNull(customer);
}

[Test]
public void FindWithJoinInCriteriaSHouldWork()
{
var adapter = new XmlMockAdapter(@"<root><Users UserKey=""System.Guid"" UserCustomers=""UserCustomers"">
<User Email=""somesiteUser"" Password=""PASSWORD"" UserType=""Customer"" UserKey=""FF47BE0F-A6AE-4B52-B7CC-B2F3CA413838"">
<UserCustomers UserKey=""System.Guid"" CustomerNo=""System.Int32"" SiteNo=""System.Int32"">
<UserCustomer UserKey=""FF47BE0F-A6AE-4B52-B7CC-B2F3CA413838"" CustomerNo=""1000"" SiteNo=""501""/>
</UserCustomers>
</User>
</Users></root>");
dynamic db = new Database(adapter);

var associatedUser =
db.Users.Find(db.Users.UserCustomers.CustomerNo == 1000 && db.Users.UserType == "Customer");

Assert.IsNotNull(associatedUser);
Assert.AreEqual(new Guid("FF47BE0F-A6AE-4B52-B7CC-B2F3CA413838"), associatedUser.UserKey);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Simple.Data.Mocking/XmlPredicateBuilder.cs
Expand Up @@ -47,7 +47,7 @@ class XmlPredicateBuilder

private static Func<XElement, XElement> BuildNestedElementResolver(IList<string> elementNames)
{
Func<XElement, XElement> resolver = xml => xml.Element(elementNames[1]);
Func<XElement, XElement> resolver = xml => xml.Element(elementNames[1]).Elements().First();
for (int i = 2; i < elementNames.Count - 1; i++)
{
var nested = resolver;
Expand Down
3 changes: 3 additions & 0 deletions Simple.Data.sln
Expand Up @@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 11.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple.Data", "Simple.Data\Simple.Data.csproj", "{148CEE80-2E84-4ABD-B5AB-20415B2BBD21}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{10F43335-5672-4BDA-91BB-5311C2BFA409}"
ProjectSection(SolutionItems) = preProject
CommonAssemblyInfo.cs = CommonAssemblyInfo.cs
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple.Data.UnitTest", "Simple.Data.UnitTest\Simple.Data.UnitTest.csproj", "{1D2908F9-A78B-4EE1-8DAA-D4DBF3937C58}"
EndProject
Expand Down

0 comments on commit 2db1dc1

Please sign in to comment.