protected override IEnumerable<Table> OnBuild() { foreach (var relationship in BluePrint.Relationships) { var factory = new LinkFactory(); var link = factory.Build(relationship.Entities.Select(e=> e.Label)); yield return link; } }
public void Build_EntitiesWithOneToMany_LinkWithCorrectUniqueKeys() { var factory = new LinkFactory(); var link = factory.Build("Student", "Course", Connectivity.OneToMany); Assert.AreEqual(1, link.UniqueKeys.Count); Assert.IsTrue(link.UniqueKeys[0].Contains(link.ForeignKeys[0])); Assert.IsTrue(link.UniqueKeys[0].Contains(link.DateKey)); }
public void Build_Entity_LinkBetweenTwoEntities() { var factory = new LinkFactory(); var link = factory.Build("Student", "Course"); Assert.IsInstanceOfType(link, typeof(Link)); Assert.IsNotNull(link); Assert.AreEqual("StudentCourseLink", link.Shortname); Assert.AreEqual("StudentId", link.ForeignKeys[0].Name); Assert.AreEqual(SqlDataType.Int, link.ForeignKeys[0].DataType.SqlDataType); Assert.AreEqual("CourseId", link.ForeignKeys[1].Name); Assert.AreEqual(SqlDataType.Int, link.ForeignKeys[1].DataType.SqlDataType); Assert.AreEqual(3, link.ForeignKeys.Count); Assert.IsTrue(link.ForeignKeys.Contains(link.DateKey)); }
public void Build_Entity_LinkWithCorrectFilters() { var factory = new LinkFactory(); var link = factory.Build("Student", "Course"); Assert.AreEqual("IsFirstDate", link.Filters[0].Name); Assert.AreEqual(SqlDataType.Bit, link.Filters[0].DataType.SqlDataType); Assert.AreEqual("IsLastDate", link.Filters[1].Name); Assert.AreEqual(SqlDataType.Bit, link.Filters[1].DataType.SqlDataType); }