@@ -149,6 +149,119 @@ public async Task ViewLocator_CanBeSetAndRetrieved()
149149 await Assert . That ( host . ViewLocator ) . IsSameReferenceAs ( locator ) ;
150150 }
151151
152+ /// <summary>
153+ /// Tests that DefaultContent getter returns null when not set.
154+ /// </summary>
155+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
156+ [ Test ]
157+ public async Task DefaultContent_WhenNotSet_ReturnsNull ( )
158+ {
159+ var host = new ViewModelViewHost < TestViewModel > ( ) ;
160+
161+ await Assert . That ( host . DefaultContent ) . IsNull ( ) ;
162+ }
163+
164+ /// <summary>
165+ /// Tests that ViewContract setter updates ViewContractObservable.
166+ /// </summary>
167+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
168+ [ Test ]
169+ public async Task ViewContract_WhenSet_UpdatesViewContractObservable ( )
170+ {
171+ var host = new ViewModelViewHost < TestViewModel > ( ) ;
172+ var originalObservable = host . ViewContractObservable ;
173+
174+ host . ViewContract = "TestContract" ;
175+
176+ // ViewContractObservable should be a different instance after setting ViewContract
177+ await Assert . That ( host . ViewContractObservable ) . IsNotSameReferenceAs ( originalObservable ) ;
178+ }
179+
180+ /// <summary>
181+ /// Tests that constructor initializes ViewContractObservable in unit test mode.
182+ /// </summary>
183+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
184+ [ Test ]
185+ public async Task Constructor_InUnitTestMode_InitializesViewContractObservable ( )
186+ {
187+ var host = new ViewModelViewHost < TestViewModel > ( ) ;
188+
189+ // In unit test mode, ViewContractObservable should be set to Observable.Never
190+ await Assert . That ( host . ViewContractObservable ) . IsNotNull ( ) ;
191+ }
192+
193+ /// <summary>
194+ /// Tests that multiple ViewModel assignments update the property.
195+ /// </summary>
196+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
197+ [ Test ]
198+ public async Task ViewModel_MultipleAssignments_UpdatesProperty ( )
199+ {
200+ var viewModel1 = new TestViewModel { Name = "First" } ;
201+ var viewModel2 = new TestViewModel { Name = "Second" } ;
202+
203+ var host = new ViewModelViewHost < TestViewModel >
204+ {
205+ ViewModel = viewModel1
206+ } ;
207+
208+ await Assert . That ( host . ViewModel ) . IsSameReferenceAs ( viewModel1 ) ;
209+
210+ host . ViewModel = viewModel2 ;
211+
212+ await Assert . That ( host . ViewModel ) . IsSameReferenceAs ( viewModel2 ) ;
213+ }
214+
215+ /// <summary>
216+ /// Tests that setting IViewFor.ViewModel to null works.
217+ /// </summary>
218+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
219+ [ Test ]
220+ public async Task IViewFor_ViewModel_CanBeSetToNull ( )
221+ {
222+ IViewFor host = new ViewModelViewHost < TestViewModel >
223+ {
224+ ViewModel = new TestViewModel ( )
225+ } ;
226+
227+ host . ViewModel = null ;
228+
229+ await Assert . That ( host . ViewModel ) . IsNull ( ) ;
230+ await Assert . That ( ( ( ViewModelViewHost < TestViewModel > ) host ) . ViewModel ) . IsNull ( ) ;
231+ }
232+
233+ /// <summary>
234+ /// Tests that IViewFor.ViewModel setter works correctly.
235+ /// </summary>
236+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
237+ [ Test ]
238+ public async Task IViewFor_ViewModelSetter_WorksCorrectly ( )
239+ {
240+ var viewModel = new TestViewModel ( ) ;
241+ IViewFor host = new ViewModelViewHost < TestViewModel > ( ) ;
242+
243+ host . ViewModel = viewModel ;
244+
245+ await Assert . That ( host . ViewModel ) . IsSameReferenceAs ( viewModel ) ;
246+ await Assert . That ( ( ( ViewModelViewHost < TestViewModel > ) host ) . ViewModel ) . IsSameReferenceAs ( viewModel ) ;
247+ }
248+
249+ /// <summary>
250+ /// Tests that ViewContractObservable can be set.
251+ /// </summary>
252+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
253+ [ Test ]
254+ public async Task ViewContractObservable_CanBeSet ( )
255+ {
256+ var observable = Observable . Return ( "TestContract" ) ;
257+ var host = new ViewModelViewHost < TestViewModel >
258+ {
259+ ViewContractObservable = observable
260+ } ;
261+
262+ await Assert . That ( host . ViewContractObservable ) . IsSameReferenceAs ( observable ) ;
263+ }
264+
152265 /// <summary>
153266 /// Test view model.
154267 /// </summary>
0 commit comments