@@ -32,7 +32,7 @@ public virtual void Can_set_complex_property_annotation()
32
32
Assert . Equal ( "bar2" , complexProperty [ "foo2" ] ) ;
33
33
Assert . Equal ( typeof ( Customer ) . Name , complexProperty . Name ) ;
34
34
Assert . Equal ( """
35
- Customer (Customer)
35
+ Customer (Customer) Required
36
36
ComplexType: ComplexProperties.Customer#Customer
37
37
Properties:
38
38
AlternateKey (Guid) Required
@@ -1507,7 +1507,7 @@ public virtual void Can_ignore_a_field()
1507
1507
}
1508
1508
1509
1509
[ ConditionalFact ]
1510
- public virtual void Complex_properties_discovered_by_convention ( )
1510
+ public virtual void Complex_properties_not_discovered_by_convention ( )
1511
1511
{
1512
1512
var modelBuilder = CreateModelBuilder ( ) ;
1513
1513
@@ -1518,10 +1518,10 @@ public virtual void Complex_properties_discovered_by_convention()
1518
1518
. Entity < ComplexProperties > ( )
1519
1519
. ComplexProperty ( e => e . Customer ) ;
1520
1520
1521
- modelBuilder
1522
- . Entity < ValueComplexProperties > ( )
1523
- . Ignore ( e => e . Tuple )
1524
- . ComplexProperty ( e => e . Label ) ;
1521
+ // modelBuilder
1522
+ // .Entity<ValueComplexProperties>()
1523
+ // .Ignore(e => e.Tuple)
1524
+ // .ComplexProperty(e => e.Label);
1525
1525
1526
1526
var model = modelBuilder . FinalizeModel ( ) ;
1527
1527
@@ -1530,26 +1530,26 @@ public virtual void Complex_properties_discovered_by_convention()
1530
1530
var indexedType = model . FindEntityType ( typeof ( ComplexProperties ) )
1531
1531
. FindComplexProperty ( nameof ( ComplexProperties . IndexedClass ) ) . ComplexType ;
1532
1532
1533
- var valueType = model . FindEntityType ( typeof ( ValueComplexProperties ) ) ;
1534
- var labelProperty = valueType . FindComplexProperty ( nameof ( ValueComplexProperties . Label ) ) ;
1535
- Assert . False ( labelProperty . IsNullable ) ;
1536
- Assert . Equal ( typeof ( ProductLabel ) , labelProperty . ClrType ) ;
1537
- var labelType = labelProperty . ComplexType ;
1538
- Assert . Equal ( typeof ( ProductLabel ) , labelType . ClrType ) ;
1539
-
1540
- var labelCustomerProperty = labelType . FindComplexProperty ( nameof ( ProductLabel . Customer ) ) ;
1541
- Assert . True ( labelCustomerProperty . IsNullable ) ;
1542
- Assert . Equal ( typeof ( Customer ) , labelCustomerProperty . ClrType ) ;
1543
-
1544
- var oldLabelProperty = valueType . FindComplexProperty ( nameof ( ValueComplexProperties . OldLabel ) ) ;
1545
- Assert . True ( oldLabelProperty . IsNullable ) ;
1546
- Assert . Equal ( typeof ( ProductLabel ? ) , oldLabelProperty . ClrType ) ;
1547
- var oldLabelType = oldLabelProperty . ComplexType ;
1548
- Assert . Equal ( typeof ( ProductLabel ) , oldLabelType . ClrType ) ;
1549
-
1550
- var oldLabelCustomerProperty = labelType . FindComplexProperty ( nameof ( ProductLabel . Customer ) ) ;
1551
- Assert . True ( oldLabelCustomerProperty . IsNullable ) ;
1552
- Assert . Equal ( typeof ( Customer ) , oldLabelCustomerProperty . ClrType ) ;
1533
+ // var valueType = model.FindEntityType(typeof(ValueComplexProperties));
1534
+ // var labelProperty = valueType.FindComplexProperty(nameof(ValueComplexProperties.Label));
1535
+ // Assert.False(labelProperty.IsNullable);
1536
+ // Assert.Equal(typeof(ProductLabel), labelProperty.ClrType);
1537
+ // var labelType = labelProperty.ComplexType;
1538
+ // Assert.Equal(typeof(ProductLabel), labelType.ClrType);
1539
+
1540
+ // var labelCustomerProperty = labelType.FindComplexProperty(nameof(ProductLabel.Customer));
1541
+ // Assert.True(labelCustomerProperty.IsNullable);
1542
+ // Assert.Equal(typeof(Customer), labelCustomerProperty.ClrType);
1543
+
1544
+ // var oldLabelProperty = valueType.FindComplexProperty(nameof(ValueComplexProperties.OldLabel));
1545
+ // Assert.True(oldLabelProperty.IsNullable);
1546
+ // Assert.Equal(typeof(ProductLabel?), oldLabelProperty.ClrType);
1547
+ // var oldLabelType = oldLabelProperty.ComplexType;
1548
+ // Assert.Equal(typeof(ProductLabel), oldLabelType.ClrType);
1549
+
1550
+ // var oldLabelCustomerProperty = labelType.FindComplexProperty(nameof(ProductLabel.Customer));
1551
+ // Assert.True(oldLabelCustomerProperty.IsNullable);
1552
+ // Assert.Equal(typeof(Customer), oldLabelCustomerProperty.ClrType);
1553
1553
}
1554
1554
1555
1555
[ ConditionalFact ]
@@ -1571,7 +1571,22 @@ public virtual void Complex_properties_can_be_configured_by_type()
1571
1571
}
1572
1572
1573
1573
[ ConditionalFact ]
1574
- public virtual void Can_map_tuple ( )
1574
+ public virtual void Throws_for_optional_complex_property ( )
1575
+ {
1576
+ var modelBuilder = CreateModelBuilder ( ) ;
1577
+
1578
+ modelBuilder
1579
+ . Entity < ComplexProperties > ( )
1580
+ . ComplexProperty ( e => e . Customer ) . IsRequired ( false ) ;
1581
+
1582
+ Assert . Equal (
1583
+ CoreStrings . ComplexPropertyOptional (
1584
+ nameof ( ComplexProperties ) , nameof ( ComplexProperties . Customer ) ) ,
1585
+ Assert . Throws < InvalidOperationException > ( modelBuilder . FinalizeModel ) . Message ) ;
1586
+ }
1587
+
1588
+ [ ConditionalFact ]
1589
+ public virtual void Throws_for_tuple ( )
1575
1590
{
1576
1591
var modelBuilder = CreateModelBuilder ( ) ;
1577
1592
@@ -1581,17 +1596,23 @@ public virtual void Can_map_tuple()
1581
1596
. Ignore ( e => e . OldLabel )
1582
1597
. ComplexProperty ( e => e . Tuple ) ;
1583
1598
1584
- var model = modelBuilder . FinalizeModel ( ) ;
1585
-
1586
- var valueType = model . FindEntityType ( typeof ( ValueComplexProperties ) ) ;
1587
- var tupleProperty = valueType . FindComplexProperty ( nameof ( ValueComplexProperties . Tuple ) ) ;
1588
- Assert . False ( tupleProperty . IsNullable ) ;
1589
- Assert . Equal ( typeof ( ( string , int ) ) , tupleProperty . ClrType ) ;
1590
- var tupleType = tupleProperty . ComplexType ;
1591
- Assert . Equal ( typeof ( ( string , int ) ) , tupleType . ClrType ) ;
1592
- Assert . Equal ( "ValueComplexProperties.Tuple#ValueTuple<string, int>" , tupleType . DisplayName ( ) ) ;
1593
-
1594
- Assert . Equal ( 2 , tupleType . GetProperties ( ) . Count ( ) ) ;
1599
+ Assert . Equal (
1600
+ CoreStrings . ValueComplexType (
1601
+ nameof ( ValueComplexProperties ) , nameof ( ValueComplexProperties . Tuple ) , typeof ( ( string , int ) ) . ShortDisplayName ( ) ) ,
1602
+ Assert . Throws < InvalidOperationException > ( modelBuilder . FinalizeModel ) . Message ) ;
1603
+
1604
+ // Uncomment when value types are supported.
1605
+ //var model = modelBuilder.FinalizeModel();
1606
+
1607
+ //var valueType = model.FindEntityType(typeof(ValueComplexProperties));
1608
+ //var tupleProperty = valueType.FindComplexProperty(nameof(ValueComplexProperties.Tuple));
1609
+ //Assert.False(tupleProperty.IsNullable);
1610
+ //Assert.Equal(typeof((string, int)), tupleProperty.ClrType);
1611
+ //var tupleType = tupleProperty.ComplexType;
1612
+ //Assert.Equal(typeof((string, int)), tupleType.ClrType);
1613
+ //Assert.Equal("ValueComplexProperties.Tuple#ValueTuple<string, int>", tupleType.DisplayName());
1614
+
1615
+ //Assert.Equal(2, tupleType.GetProperties().Count());
1595
1616
}
1596
1617
1597
1618
[ ConditionalFact ]
0 commit comments