public void GetMethodChain_returns_body_when_name() { var configuration = new ColumnConfiguration { Name = "Id" }; var code = new CSharpCodeHelper(); Assert.Equal(".HasColumnName(\"Id\")", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_body_when_order() { var configuration = new ColumnConfiguration { Order = 0 }; var code = new CSharpCodeHelper(); Assert.Equal(".HasColumnOrder(0)", configuration.GetMethodChain(code)); }
public void GetAttributeBody_returns_body_when_order() { var configuration = new ColumnConfiguration { Order = 0 }; var code = new CSharpCodeHelper(); Assert.Equal("Column(Order = 0)", configuration.GetAttributeBody(code)); }
public void GetAttributeBody_returns_body_when_all() { var configuration = new ColumnConfiguration { Name = "Id", Order = 0, TypeName = "int" }; var code = new CSharpCodeHelper(); Assert.Equal("Column(\"Id\", Order = 0, TypeName = \"int\")", configuration.GetAttributeBody(code)); }
public void GetMethodChain_returns_chain_when_one_key_property() { var configuration = new KeyConfiguration { KeyProperties = { new EdmProperty("Id") } }; var code = new CSharpCodeHelper(); Assert.Equal(".HasKey(e => e.Id)", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chan_when_many_to_many() { var modelBuilder = new DbModelBuilder(); modelBuilder.Entity<Entity1>().HasMany(e => e.Entity2s).WithMany(e => e.Entity1s); modelBuilder.Entity<Entity1>().Ignore(e => e.Entity2); var model = modelBuilder.Build(new DbProviderInfo("System.Data.SqlClient", "2012")); var entityType = model.ConceptualModel.EntityTypes.First(t => t.Name == "Entity1"); var navigationProperty = entityType.NavigationProperties.First(p => p.Name == "Entity2s"); var otherEntityType = model.ConceptualModel.EntityTypes.First(t => t.Name == "Entity2"); var otherNavigationProperty = otherEntityType.NavigationProperties.First(p => p.Name == "Entity1s"); var configuration = new MultiplicityConfiguration { LeftEntityType = entityType, LeftNavigationProperty = navigationProperty, RightNavigationProperty = otherNavigationProperty }; var code = new CSharpCodeHelper(); Assert.Equal( @".Entity<Entity1>() .HasMany(e => e.Entity2s) .WithMany(e => e.Entity1s)", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chain_when_table() { var configuration = new JoinTableConfiguration { Table = "Subscriptions" }; var code = new CSharpCodeHelper(); Assert.Equal(".Map(m => m.ToTable(\"Subscriptions\"))", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chain() { var configuration = new FixedLengthConfiguration(); var code = new CSharpCodeHelper(); Assert.Equal(".IsFixedLength()", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chain_when_one_left_key() { var configuration = new JoinTableConfiguration { LeftKeys = { "CustomerId" } }; var code = new CSharpCodeHelper(); Assert.Equal(".Map(m => m.MapLeftKey(\"CustomerId\"))", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chain_when_one_right_key() { var configuration = new JoinTableConfiguration { RightKeys = { "ServiceId" } }; var code = new CSharpCodeHelper(); Assert.Equal(".Map(m => m.MapRightKey(\"ServiceId\"))", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chain() { var configuration = new NonUnicodeConfiguration(); var code = new CSharpCodeHelper(); Assert.Equal(".IsUnicode(false)", configuration.GetMethodChain(code)); }
public void GetAttributeBody_returns_body() { var configuration = new TimestampConfiguration(); var code = new CSharpCodeHelper(); Assert.Equal("Timestamp", configuration.GetAttributeBody(code)); }
public void GetMethodChain_returns_chain() { var configuration = new TimestampConfiguration(); var code = new CSharpCodeHelper(); Assert.Equal(".IsRowVersion()", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_body_when_type() { var configuration = new ColumnConfiguration { TypeName = "int" }; var code = new CSharpCodeHelper(); Assert.Equal(".HasColumnType(\"int\")", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chain() { var configuration = new PrecisionDateTimeConfiguration { Precision = 4 }; var code = new CSharpCodeHelper(); Assert.Equal(".HasPrecision(4)", configuration.GetMethodChain(code)); }
public void GetAttributeBody_returns_body_when_name() { var configuration = new ColumnConfiguration { Name = "Id" }; var code = new CSharpCodeHelper(); Assert.Equal("Column(\"Id\")", configuration.GetAttributeBody(code)); }
public void GetAttributeBody_returns_body() { var configuration = new TableConfiguration { Table = "Entities" }; var code = new CSharpCodeHelper(); Assert.Equal("Table(\"Entities\")", configuration.GetAttributeBody(code)); }
public void Type_returns_type_name() { var container = Model.ConceptualModel.EntityTypes.First(); var code = new CSharpCodeHelper(); Assert.Equal("Entity", code.Type(container)); }
public void GetAttributeBody_returns_body() { var configuration = new KeyPropertyConfiguration(); var code = new CSharpCodeHelper(); Assert.Equal("Key", configuration.GetAttributeBody(code)); }
public void Property_returns_member_name() { var member = Model.ConceptualModel.EntityTypes.First().Properties.First(p => p.Name == "Id"); var code = new CSharpCodeHelper(); Assert.Equal("Id", code.Property(member)); }
public void Property_returns_entity_set_name() { var entitySet = Model.ConceptualModel.Container.EntitySets.First(); var code = new CSharpCodeHelper(); Assert.Equal("Entities", code.Property(entitySet)); }
public void GetMethodChain_returns_chain() { var configuration = new RequiredConfiguration(); var code = new CSharpCodeHelper(); Assert.Equal(".IsRequired()", configuration.GetMethodChain(code)); }
public void Lambda_returns_property_accessor_when_one() { var code = new CSharpCodeHelper(); var member = Model.ConceptualModel.EntityTypes.First().Properties.First(p => p.Name == "Id"); Assert.Equal("e => e.Id", code.Lambda(member)); }
public void GetMethodChain_returns_chain() { var configuration = new MaxLengthConfiguration { MaxLength = 30 }; var code = new CSharpCodeHelper(); Assert.Equal(".HasMaxLength(30)", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chan_when_required_to_many() { var modelBuilder = new DbModelBuilder(); modelBuilder.Entity <Entity1>().HasRequired(e => e.Entity2).WithMany(e => e.Entity1s); var model = modelBuilder.Build(new DbProviderInfo("System.Data.SqlClient", "2012")); var entityType = model.ConceptualModel.EntityTypes.First(t => t.Name == "Entity1"); var navigationProperty = entityType.NavigationProperties.First(p => p.Name == "Entity2"); var otherEntityType = model.ConceptualModel.EntityTypes.First(t => t.Name == "Entity2"); var otherNavigationProperty = otherEntityType.NavigationProperties.First(p => p.Name == "Entity1s"); var configuration = new MultiplicityConfiguration { LeftEntityType = entityType, LeftNavigationProperty = navigationProperty, RightNavigationProperty = otherNavigationProperty }; var code = new CSharpCodeHelper(); Assert.Equal( @".Entity<Entity1>() .HasRequired(e => e.Entity2) .WithMany(e => e.Entity1s)", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_body() { var configuration = new TableConfiguration { Table = "Entities" }; var code = new CSharpCodeHelper(); Assert.Equal(".ToTable(\"Entities\")", configuration.GetMethodChain(code)); }
public void Type_returns_container_name() { var container = Model.ConceptualModel.Container; var code = new CSharpCodeHelper(); Assert.Equal("CodeFirstContainer", code.Type(container)); }
public void GetAttributeBody_returns_body() { var configuration = new MaxLengthConfiguration { MaxLength = 30 }; var code = new CSharpCodeHelper(); Assert.Equal("MaxLength(30)", configuration.GetAttributeBody(code)); }
public void GetAttributeBody_returns_body() { var configuration = new RequiredConfiguration(); var code = new CSharpCodeHelper(); Assert.Equal("Required", configuration.GetAttributeBody(code)); }
public void GetMethodChain_returns_chain_when_none() { var configuration = new CascadeDeleteConfiguration { DeleteBehavior = OperationAction.None }; var code = new CSharpCodeHelper(); Assert.Equal(".WillCascadeOnDelete(false)", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chain_when_one_property() { var configuration = new ForeignKeyConfiguration { Properties = { new EdmProperty("EntityId") } }; var code = new CSharpCodeHelper(); Assert.Equal(".HasForeignKey(e => e.EntityId)", configuration.GetMethodChain(code)); }
public void GetMethodChain_returns_chain() { var configuration = new PrecisionDecimalConfiguration { Precision = 8, Scale = 2 }; var code = new CSharpCodeHelper(); Assert.Equal(".HasPrecision(8, 2)", configuration.GetMethodChain(code)); }
public void Literal_returns_bool() { var code = new CSharpCodeHelper(); Assert.Equal("true", code.Literal(true)); Assert.Equal("false", code.Literal(false)); }
public void Type_unqualifies_property_type() { var property = Model.ConceptualModel.EntityTypes.First().Properties.First( p => p.Name == "Guid"); var code = new CSharpCodeHelper(); Assert.Equal("Guid", code.Type(property)); }
public void Type_returns_collection_property_type() { var property = Model.ConceptualModel.EntityTypes.First().NavigationProperties.First( p => p.Name == "Children"); var code = new CSharpCodeHelper(); Assert.Equal("ICollection<Entity>", code.Type(property)); }
public void Type_escapes_container_name() { var container = new Mock<EntityContainer>(); container.SetupGet(c => c.Name).Returns("null"); var code = new CSharpCodeHelper(); Assert.Equal("_null", code.Type(container.Object)); }
public void MethodChain_evaluates_preconditions() { var code = new CSharpCodeHelper(); var ex = Assert.Throws <ArgumentNullException>(() => code.MethodChain(null)); Assert.Equal("configuration", ex.ParamName); }
public void Lambda_returns_anonymous_type_when_one() { var code = new CSharpCodeHelper(); var id = Model.ConceptualModel.EntityTypes.First().Properties.First(p => p.Name == "Id"); var name = Model.ConceptualModel.EntityTypes.First().Properties.First(p => p.Name == "Name"); Assert.Equal("e => new { e.Id, e.Name }", code.Lambda(new[] { id, name })); }
public void Type_escapes_type_name() { var type = new Mock<EdmType>(); type.SetupGet(c => c.Name).Returns("null"); var code = new CSharpCodeHelper(); Assert.Equal("_null", code.Type(type.Object)); }
public void Type_returns_reference_property_type() { var property = Model.ConceptualModel.EntityTypes.First().NavigationProperties.First( p => p.Name == "Parent"); var code = new CSharpCodeHelper(); Assert.Equal("Entity", code.Type(property)); }
public void Type_returns_property_type() { var property = Model.ConceptualModel.EntityTypes.First().Properties.First( p => p.Name == "Name"); var code = new CSharpCodeHelper(); Assert.Equal("string", code.Type(property)); }
public void Type_returns_nullable_value_property_type() { var property = Model.ConceptualModel.EntityTypes.First().Properties.First( p => p.Name == "ParentId"); var code = new CSharpCodeHelper(); Assert.Equal("int?", code.Type(property)); }