@@ -108,7 +108,7 @@ public async Task TestModelCanReferenceSameForeignTableMultipleTimes()
108108 Assert . IsInstanceOfType ( response . Model ! . MovieFK2 , typeof ( Movie ) ) ;
109109 Assert . IsInstanceOfType ( response . Model ! . RandomPersonFK , typeof ( Person ) ) ;
110110 }
111-
111+
112112 [ TestMethod ( "Reference: Table can reference a nested model with the same foreign table multiple times." ) ]
113113 public async Task TestModelCanReferenceNestedModelWithSameForeignTableMultipleTimes ( )
114114 {
@@ -120,5 +120,35 @@ public async Task TestModelCanReferenceNestedModelWithSameForeignTableMultipleTi
120120 Assert . IsInstanceOfType ( response . Model ! . User , typeof ( User ) ) ;
121121 Assert . IsInstanceOfType ( response . Model ! . FKTestModel , typeof ( ForeignKeyTestModel ) ) ;
122122 }
123+
124+ [ TestMethod ( "Reference: Model inserts and updates (ignoring reference properties) when Reference is not null." ) ]
125+ public async Task TestModelInsertsAndUpdatesWhenReferenceIsSpecified ( )
126+ {
127+ var client = new Client ( BaseUrl ) ;
128+
129+ var newModel = new Movie ( )
130+ {
131+ Name = "The Blue Eyed Samurai (Movie)" ,
132+ Status = MovieStatus . OffDisplay ,
133+ People =
134+ [
135+ new Person { FirstName = "Maya" , LastName = "Erskine" } ,
136+ new Person { FirstName = "Masi" , LastName = "Oka" }
137+ ]
138+ } ;
139+
140+ var insertedModel = await client . Table < Movie > ( ) . Insert ( newModel ) ;
141+
142+ Assert . IsNotNull ( insertedModel . Model ) ;
143+ Assert . IsNotNull ( insertedModel . Model . Name ) ;
144+ Assert . AreEqual ( MovieStatus . OffDisplay , insertedModel . Model . Status ) ;
145+
146+ insertedModel . Model . Status = MovieStatus . OnDisplay ;
147+
148+ var updatedModel = await insertedModel . Model . Update < Movie > ( ) ;
149+
150+ Assert . IsNotNull ( updatedModel . Model ) ;
151+ Assert . AreEqual ( MovieStatus . OnDisplay , updatedModel . Model . Status ) ;
152+ }
123153 }
124154}
0 commit comments