public void WhenTableIsForeignKeyTable_ShouldReturnNavigationProperty() { //Arrange ISchemaTable table = new SqlSchemaTable( schema: "dbo", name : "SagaMessage", isView: false); ISchemaForeignKey foreignKey = new SqlSchemaForeignKey( foreignKeySchema : "dbo", foreignKeyTableName: "SagaMessage", foreignKeyColumn : "SagaId", primaryKeySchema : "dbo", primaryKeyTableName: "Saga", primaryKeyColumn : "SagaId", constraintName : "FK_SagaMessage_Saga_SagaId"); AutoFaker.Provide(table); AutoFaker.Provide(foreignKey); AutoFaker.Provide<INavigationPropertyInfoAdapter, NavigationPropertyInfoAdapter>(); A.CallTo(() => AutoFaker.Resolve<IReverseEngineeringConfiguration>().Pluralize).Returns(true); //Act var result = AutoFaker.Resolve<INavigationPropertyInfoAdapter>().GetPropertyText(); //Assert result.ShouldBeEquivalentTo( "public virtual Saga Saga { get; set; } // FK_SagaMessage_Saga_SagaId"); }
public void WhenTableIsForeignKeyTable_ShouldReturnMap() { //Arrange ISchemaTable table = new SqlSchemaTable( schema: "dbo", name : "SagaMessage", isView: false); ISchemaForeignKey foreignKey = new SqlSchemaForeignKey( foreignKeySchema : "dbo", foreignKeyTableName: "SagaMessage", foreignKeyColumn : "SagaId", primaryKeySchema : "dbo", primaryKeyTableName: "Saga", primaryKeyColumn : "SagaId", constraintName : "FK_SagaMessage_Saga_SagaId"); AutoFaker.Provide(table); AutoFaker.Provide(foreignKey); AutoFaker.Provide<INavigationPropertyInfoAdapter, NavigationPropertyInfoAdapter>(); A.CallTo(() => AutoFaker.Resolve<IReverseEngineeringConfiguration>().Pluralize).Returns(true); //Act var result = AutoFaker.Resolve<INavigationPropertyInfoAdapter>().GetMapppingText(); //Assert result.ShouldBeEquivalentTo( @"HasRequired(a => a.Saga).WithMany(b => b.SagaMessages).HasForeignKey(c => c.SagaId); // FK_SagaMessage_Saga_SagaId"); }