Skip to content

Commit

Permalink
New test.
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-tkachev committed May 2, 2013
1 parent 86124c3 commit 7428cf8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Data/Create Scripts/Firebird2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ AS
BEGIN
FOR
SELECT
Person.PersonID,
Person.PersonID,
FirstName,
LastName,
MiddleName,
Expand All @@ -293,10 +293,10 @@ BEGIN
WHERE
Patient.PersonID = Person.PersonID
INTO
:PersonID,
:FirstName,
:LastName,
:MiddleName,
:PersonID,
:FirstName,
:LastName,
:MiddleName,
:Gender,
:Diagnosis
DO SUSPEND;
Expand Down
51 changes: 50 additions & 1 deletion UnitTests/Linq/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using BLToolkit.DataAccess;
using BLToolkit.EditableObjects;
using BLToolkit.Mapping;

using BLToolkit.Reflection;
using NUnit.Framework;

using Convert = System.Convert;
Expand Down Expand Up @@ -393,5 +393,54 @@ public void TestMethod()
Assert.IsNotNull(str);
}
}

[TableName("Parent")]
public abstract class ParentX
{
[MapField("ParentID")]
public abstract int ParentID { get; set; }
[MapField("Value1")]
public abstract int? Value1 { get; set; }
}

[TableName("Child")]
[MapField("ParentID", "Parent.ParentID")]
public abstract class ChildX
{
[MapField("ChildID")]
public abstract int ChildID { get; set; }
public abstract ParentX Parent { get; set; }
}

[Test]
public void Test4([DataContexts] string contexts)
{
using (var db = GetDataContext(contexts))
{
db.Child. Delete(p => p.ParentID == 1001);
db.Parent.Delete(p => p.ParentID == 1001);

try
{
var child = TypeAccessor.CreateInstance<ChildX>();
var parent = TypeAccessor.CreateInstance<ParentX>();

parent.ParentID = 1001;
parent.Value1 = 1;

db.Insert(parent);

child.ChildID = 1001;
child.Parent = parent;

db.Insert(child);
}
finally
{
db.Child. Delete(p => p.ParentID == 1001);
db.Parent.Delete(p => p.ParentID == 1001);
}
}
}
}
}

0 comments on commit 7428cf8

Please sign in to comment.