public void SimpleManyToOneTest()
        {
            var discoverer = new RelationshipDiscoverer(new List<Type>
            {
                typeof(Models.SimpleManyToOneTestModel1),
                typeof(Models.SimpleManyToOneTestModel2)
            });

            Assert.Equal(2, discoverer.Discovered.Count);

            var relation1 = discoverer.Discovered[0];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.MtoO, relation1.Type);
            Assert.Equal(typeof(Models.SimpleManyToOneTestModel1), relation1.LocalType);
            Assert.Equal(typeof(Models.SimpleManyToOneTestModel2), relation1.ForeignType);
            Assert.Equal(typeof(Models.SimpleManyToOneTestModel1).GetProperty("Foos"), relation1.LocalProperty);
            Assert.Equal(typeof(Models.SimpleManyToOneTestModel2).GetProperty("Bar"), relation1.ForeignProperty);
            Assert.Equal("SimpleManyToOneTestModel1s", relation1.LocalTableName);
            Assert.Equal("SimpleManyToOneTestModel2s", relation1.ForeignTableName);
            Assert.Equal("SimpleManyToOneTestModel1", relation1.LocalTableNameSingular);
            Assert.Equal("SimpleManyToOneTestModel2", relation1.ForeignTableNameSingular);
            Assert.Equal("SimpleManyToOneTestModel2s", relation1.ForeignKeyTableName);
            Assert.Equal("SimpleManyToOneTestModel1Id", relation1.ForeignKeyColumnName);
            Assert.Equal(null, relation1.PivotTableName);
            Assert.Equal(null, relation1.PivotTableFirstColumnName);
            Assert.Equal(null, relation1.PivotTableSecondColumnName);
            Assert.Equal(null, relation1.LinkIdentifier);

            var relation2 = discoverer.Discovered[1];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.OtoM, relation2.Type);
            Assert.Equal(typeof(Models.SimpleManyToOneTestModel2), relation2.LocalType);
            Assert.Equal(typeof(Models.SimpleManyToOneTestModel1), relation2.ForeignType);
            Assert.Equal(typeof(Models.SimpleManyToOneTestModel2).GetProperty("Bar"), relation2.LocalProperty);
            Assert.Equal(typeof(Models.SimpleManyToOneTestModel1).GetProperty("Foos"), relation2.ForeignProperty);
            Assert.Equal("SimpleManyToOneTestModel2s", relation2.LocalTableName);
            Assert.Equal("SimpleManyToOneTestModel1s", relation2.ForeignTableName);
            Assert.Equal("SimpleManyToOneTestModel2", relation2.LocalTableNameSingular);
            Assert.Equal("SimpleManyToOneTestModel1", relation2.ForeignTableNameSingular);
            Assert.Equal("SimpleManyToOneTestModel2s", relation2.ForeignKeyTableName);
            Assert.Equal("SimpleManyToOneTestModel1Id", relation2.ForeignKeyColumnName);
            Assert.Equal(null, relation2.PivotTableName);
            Assert.Equal(null, relation2.PivotTableFirstColumnName);
            Assert.Equal(null, relation2.PivotTableSecondColumnName);
            Assert.Equal(null, relation2.LinkIdentifier);
        }
        public void LazyOneToOneTest()
        {
            var discoverer = new RelationshipDiscoverer(new List<Type>
            {
                typeof(Models.LazyOneToOneTestModel1),
                typeof(Models.LazyOneToOneTestModel2),
                typeof(Models.LazyOneToOneTestModel3)
            });

            Assert.Equal(3, discoverer.Discovered.Count);

            var relation1 = discoverer.Discovered[0];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.OtoO, relation1.Type);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel1), relation1.LocalType);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel2), relation1.ForeignType);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel1).GetProperty("Foo"), relation1.LocalProperty);
            Assert.Equal(null, relation1.ForeignProperty);
            Assert.Equal("LazyOneToOneTestModel1s", relation1.LocalTableName);
            Assert.Equal("LazyOneToOneTestModel2s", relation1.ForeignTableName);
            Assert.Equal("LazyOneToOneTestModel1", relation1.LocalTableNameSingular);
            Assert.Equal("LazyOneToOneTestModel2", relation1.ForeignTableNameSingular);
            Assert.Equal("LazyOneToOneTestModel1s", relation1.ForeignKeyTableName);
            Assert.Equal("LazyOneToOneTestModel2Id", relation1.ForeignKeyColumnName);
            Assert.Equal(null, relation1.PivotTableName);
            Assert.Equal(null, relation1.PivotTableFirstColumnName);
            Assert.Equal(null, relation1.PivotTableSecondColumnName);
            Assert.Equal(null, relation1.LinkIdentifier);

            var relation2 = discoverer.Discovered[1];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.OtoO, relation2.Type);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel1), relation2.LocalType);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel3), relation2.ForeignType);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel1).GetProperty("Bar"), relation2.LocalProperty);
            Assert.Equal(null, relation2.ForeignProperty);
            Assert.Equal("LazyOneToOneTestModel1s", relation2.LocalTableName);
            Assert.Equal("LazyOneToOneTestModel3s", relation2.ForeignTableName);
            Assert.Equal("LazyOneToOneTestModel1", relation2.LocalTableNameSingular);
            Assert.Equal("LazyOneToOneTestModel3", relation2.ForeignTableNameSingular);
            Assert.Equal("LazyOneToOneTestModel1s", relation2.ForeignKeyTableName);
            Assert.Equal("LazyOneToOneTestModel3BarId", relation2.ForeignKeyColumnName);
            Assert.Equal(null, relation2.PivotTableName);
            Assert.Equal(null, relation2.PivotTableFirstColumnName);
            Assert.Equal(null, relation2.PivotTableSecondColumnName);
            Assert.Equal("Bar", relation2.LinkIdentifier);

            var relation3 = discoverer.Discovered[2];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.OtoO, relation3.Type);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel1), relation3.LocalType);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel3), relation3.ForeignType);
            Assert.Equal(typeof(Models.LazyOneToOneTestModel1).GetProperty("Baz"), relation3.LocalProperty);
            Assert.Equal(null, relation3.ForeignProperty);
            Assert.Equal("LazyOneToOneTestModel1s", relation3.LocalTableName);
            Assert.Equal("LazyOneToOneTestModel3s", relation3.ForeignTableName);
            Assert.Equal("LazyOneToOneTestModel1", relation3.LocalTableNameSingular);
            Assert.Equal("LazyOneToOneTestModel3", relation3.ForeignTableNameSingular);
            Assert.Equal("LazyOneToOneTestModel1s", relation3.ForeignKeyTableName);
            Assert.Equal("LazyOneToOneTestModel3BazId", relation3.ForeignKeyColumnName);
            Assert.Equal(null, relation3.PivotTableName);
            Assert.Equal(null, relation3.PivotTableFirstColumnName);
            Assert.Equal(null, relation3.PivotTableSecondColumnName);
            Assert.Equal("Baz", relation3.LinkIdentifier);
        }
        public void MultipleManyToManyTest()
        {
            var discoverer = new RelationshipDiscoverer(new List<Type>
            {
                typeof(Models.MultipleManyToManyTestModel1),
                typeof(Models.MultipleManyToManyTestModel2)
            });

            Assert.Equal(4, discoverer.Discovered.Count);

            var relation1 = discoverer.Discovered[0];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.MtoM, relation1.Type);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel1), relation1.LocalType);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel2), relation1.ForeignType);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel1).GetProperty("FooMultipleManyToManyTestModel2s"), relation1.LocalProperty);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel2).GetProperty("FooMultipleManyToManyTestModel1s"), relation1.ForeignProperty);
            Assert.Equal("MultipleManyToManyTestModel1s", relation1.LocalTableName);
            Assert.Equal("MultipleManyToManyTestModel2s", relation1.ForeignTableName);
            Assert.Equal("MultipleManyToManyTestModel1", relation1.LocalTableNameSingular);
            Assert.Equal("MultipleManyToManyTestModel2", relation1.ForeignTableNameSingular);
            Assert.Equal(null, relation1.ForeignKeyTableName);
            Assert.Equal(null, relation1.ForeignKeyColumnName);
            Assert.Equal("MultipleManyToManyTestModel1sFooMultipleManyToManyTestModel2s", relation1.PivotTableName);
            Assert.Equal("MultipleManyToManyTestModel1Id", relation1.PivotTableFirstColumnName);
            Assert.Equal("MultipleManyToManyTestModel2Id", relation1.PivotTableSecondColumnName);
            Assert.Equal("Foo", relation1.LinkIdentifier);

            var relation2 = discoverer.Discovered[1];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.MtoM, relation2.Type);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel1), relation2.LocalType);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel2), relation2.ForeignType);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel1).GetProperty("BarMultipleManyToManyTestModel2s"), relation2.LocalProperty);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel2).GetProperty("BarMultipleManyToManyTestModel1s"), relation2.ForeignProperty);
            Assert.Equal("MultipleManyToManyTestModel1s", relation2.LocalTableName);
            Assert.Equal("MultipleManyToManyTestModel2s", relation2.ForeignTableName);
            Assert.Equal("MultipleManyToManyTestModel1", relation2.LocalTableNameSingular);
            Assert.Equal("MultipleManyToManyTestModel2", relation2.ForeignTableNameSingular);
            Assert.Equal(null, relation2.ForeignKeyTableName);
            Assert.Equal(null, relation2.ForeignKeyColumnName);
            Assert.Equal("MultipleManyToManyTestModel1sBarMultipleManyToManyTestModel2s", relation2.PivotTableName);
            Assert.Equal("MultipleManyToManyTestModel1Id", relation2.PivotTableFirstColumnName);
            Assert.Equal("MultipleManyToManyTestModel2Id", relation2.PivotTableSecondColumnName);
            Assert.Equal("Bar", relation2.LinkIdentifier);

            var relation3 = discoverer.Discovered[2];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.MtoM, relation3.Type);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel2), relation3.LocalType);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel1), relation3.ForeignType);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel2).GetProperty("FooMultipleManyToManyTestModel1s"), relation3.LocalProperty);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel1).GetProperty("FooMultipleManyToManyTestModel2s"), relation3.ForeignProperty);
            Assert.Equal("MultipleManyToManyTestModel2s", relation3.LocalTableName);
            Assert.Equal("MultipleManyToManyTestModel1s", relation3.ForeignTableName);
            Assert.Equal("MultipleManyToManyTestModel2", relation3.LocalTableNameSingular);
            Assert.Equal("MultipleManyToManyTestModel1", relation3.ForeignTableNameSingular);
            Assert.Equal(null, relation3.ForeignKeyTableName);
            Assert.Equal(null, relation3.ForeignKeyColumnName);
            Assert.Equal("MultipleManyToManyTestModel1sFooMultipleManyToManyTestModel2s", relation3.PivotTableName);
            Assert.Equal("MultipleManyToManyTestModel1Id", relation3.PivotTableFirstColumnName);
            Assert.Equal("MultipleManyToManyTestModel2Id", relation3.PivotTableSecondColumnName);
            Assert.Equal("Foo", relation3.LinkIdentifier);

            var relation4 = discoverer.Discovered[3];
            Assert.Equal(RelationshipDiscoverer.Relation.RelationType.MtoM, relation4.Type);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel2), relation4.LocalType);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel1), relation4.ForeignType);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel2).GetProperty("BarMultipleManyToManyTestModel1s"), relation4.LocalProperty);
            Assert.Equal(typeof(Models.MultipleManyToManyTestModel1).GetProperty("BarMultipleManyToManyTestModel2s"), relation4.ForeignProperty);
            Assert.Equal("MultipleManyToManyTestModel2s", relation4.LocalTableName);
            Assert.Equal("MultipleManyToManyTestModel1s", relation4.ForeignTableName);
            Assert.Equal("MultipleManyToManyTestModel2", relation4.LocalTableNameSingular);
            Assert.Equal("MultipleManyToManyTestModel1", relation4.ForeignTableNameSingular);
            Assert.Equal(null, relation4.ForeignKeyTableName);
            Assert.Equal(null, relation4.ForeignKeyColumnName);
            Assert.Equal("MultipleManyToManyTestModel1sBarMultipleManyToManyTestModel2s", relation4.PivotTableName);
            Assert.Equal("MultipleManyToManyTestModel1Id", relation4.PivotTableFirstColumnName);
            Assert.Equal("MultipleManyToManyTestModel2Id", relation4.PivotTableSecondColumnName);
            Assert.Equal("Bar", relation4.LinkIdentifier);
        }