File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
UnitTests/UnitTests.NetCore/Mvvm Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
5+ using System . Collections . Generic ;
56using System . ComponentModel ;
67using System . Diagnostics . CodeAnalysis ;
78using System . Reflection ;
@@ -75,5 +76,36 @@ public void Test_INotifyPropertyChanged_WithoutHelpers()
7576 public partial class SampleModelWithoutHelpers
7677 {
7778 }
79+
80+ [ TestCategory ( "Mvvm" ) ]
81+ [ TestMethod ]
82+ public void Test_INotifyPropertyChanged_WithGeneratedProperties ( )
83+ {
84+ Assert . IsTrue ( typeof ( INotifyPropertyChanged ) . IsAssignableFrom ( typeof ( SampleModelWithINPCAndObservableProperties ) ) ) ;
85+ Assert . IsFalse ( typeof ( INotifyPropertyChanging ) . IsAssignableFrom ( typeof ( SampleModelWithINPCAndObservableProperties ) ) ) ;
86+
87+ SampleModelWithINPCAndObservableProperties model = new ( ) ;
88+ List < PropertyChangedEventArgs > eventArgs = new ( ) ;
89+
90+ model . PropertyChanged += ( s , e ) => eventArgs . Add ( e ) ;
91+
92+ model . X = 42 ;
93+ model . Y = 66 ;
94+
95+ Assert . AreEqual ( eventArgs . Count , 2 ) ;
96+ Assert . AreEqual ( eventArgs [ 0 ] . PropertyName , nameof ( SampleModelWithINPCAndObservableProperties . X ) ) ;
97+ Assert . AreEqual ( eventArgs [ 1 ] . PropertyName , nameof ( SampleModelWithINPCAndObservableProperties . Y ) ) ;
98+ }
99+
100+ // See https://github.com/CommunityToolkit/WindowsCommunityToolkit/issues/3665
101+ [ INotifyPropertyChanged ]
102+ public partial class SampleModelWithINPCAndObservableProperties
103+ {
104+ [ ObservableProperty ]
105+ private int x ;
106+
107+ [ ObservableProperty ]
108+ private int y ;
109+ }
78110 }
79111}
You can’t perform that action at this time.
0 commit comments