Skip to content

Commit

Permalink
Merge branch 'complex-types-take-2'
Browse files Browse the repository at this point in the history
* Implements complex type handling. (#17)
* Implements handling of renamed properties/columns (more likely in complex types). (#19)
* Significant refactoring and cleanup.
* Fully test-driven development, with coverage of all the newly supported variations.
* Preparation for handling multiple RDBMSs by factoring out adding interface to db handling (#16)

issue #16
fixes #17
fixes #19
  • Loading branch information
timabell committed Feb 21, 2015
2 parents 992ad6d + 3e431a7 commit bef661a
Show file tree
Hide file tree
Showing 14 changed files with 540 additions and 192 deletions.
3 changes: 3 additions & 0 deletions EFTests/EFTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Model\Category.cs" />
<Compile Include="Model\Pedigree.cs" />
<Compile Include="Model\Truck.cs" />
<Compile Include="Model\Car.cs" />
<Compile Include="Model\Vehicle.cs" />
Expand All @@ -68,6 +69,8 @@
<Compile Include="Db\MagicContext.cs" />
<Compile Include="Model\Constants.cs" />
<Compile Include="Model\Echo.cs" />
<Compile Include="Model\Eon.cs" />
<Compile Include="Model\Geology.cs" />
<Compile Include="Model\Heat.cs" />
<Compile Include="Model\Importance.cs" />
<Compile Include="Model\Pattern.cs" />
Expand Down
11 changes: 11 additions & 0 deletions EFTests/Model/Eon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace EFTests.Model
{
/// <summary>
/// Only findable via the complex type Geology
/// </summary>
public enum Eon
{
Old,
ReallyOld,
}
}
15 changes: 15 additions & 0 deletions EFTests/Model/Geology.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations.Schema;

namespace EFTests.Model
{
public class Geology
{
// no id to make this a complex type to be included in the Warren
public string Soil { get; set; }
public int Density { get; set; }
public Eon? Eon { get; set; }

[Column("PreviousEon")] // supress the "Geology_" prefix that you'd normally get
public Eon? PreviousEon { get; set; }
}
}
9 changes: 9 additions & 0 deletions EFTests/Model/Pedigree.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace EFTests.Model
{
public enum Pedigree
{
Dubious,
Pure,
Inbred
}
}
7 changes: 6 additions & 1 deletion EFTests/Model/Rabbit.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace EFTests.Model
using System.ComponentModel.DataAnnotations.Schema;

namespace EFTests.Model
{
public class Rabbit
{
Expand All @@ -11,5 +13,8 @@ public class Rabbit
public Legs? SpeedyLegs { get; set; }

public Relation? Offspring { get; set; }

[Column("Lineage")]
public Pedigree Pedigree { get; set; }
}
}
3 changes: 3 additions & 0 deletions EFTests/Model/Warren.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ public class Warren
public Heat? HowHot { get; set; }

public ICollection<Aspirations> HopesAndDreams { get; set; }

// complex type:
public Geology Geology { get; set; }
}
}
6 changes: 4 additions & 2 deletions EFTests/Tests/ModelParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ public void FindsReferences()
IList<EnumReference> references;
using (var context = new MagicContext())
{
references = _enumToLookup.FindReferences(context);
references = _enumToLookup.FindEnumReferences(context);
}
var legs = references.SingleOrDefault(r => r.ReferencingField == "SpeedyLegs");
Assert.IsNotNull(legs, "SpeedyLegs ref not found");
var ears = references.SingleOrDefault(r => r.ReferencingField == "TehEars");
Assert.IsNotNull(ears, "TehEars ref not found");
var echos = references.SingleOrDefault(r => r.ReferencingField == "EchoType");
Assert.IsNotNull(echos, "EchoType ref not found");
var eons = references.Count(r => r.EnumType == typeof(Eon));
Assert.AreEqual(2, eons, "Wrong number of Eon refs found");
Assert.IsTrue(references.All(r => r.EnumType.IsEnum), "Non-enum type found");
Assert.AreEqual(8, references.Count);
Assert.AreEqual(11, references.Count);
}

[Test]
Expand Down
5 changes: 5 additions & 0 deletions EfEnumToLookup/EfEnumToLookup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@
<ItemGroup>
<Compile Include="LookupGenerator\EnumGeneratorException.cs" />
<Compile Include="LookupGenerator\EnumToLookup.cs" />
<Compile Include="LookupGenerator\IDbHandler.cs" />
<Compile Include="LookupGenerator\IEnumToLookup.cs" />
<Compile Include="LookupGenerator\EnumReference.cs" />
<Compile Include="LookupGenerator\LookupData.cs" />
<Compile Include="LookupGenerator\LookupValue.cs" />
<Compile Include="LookupGenerator\MetadataHandler.cs" />
<Compile Include="LookupGenerator\RuntimeOnlyAttribute.cs" />
<Compile Include="LookupGenerator\SqlServerHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit bef661a

Please sign in to comment.