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 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ using System . Collections . Generic ;
5
6
using System . ComponentModel ;
6
7
using System . Diagnostics . CodeAnalysis ;
7
8
using System . Reflection ;
@@ -75,5 +76,36 @@ public void Test_INotifyPropertyChanged_WithoutHelpers()
75
76
public partial class SampleModelWithoutHelpers
76
77
{
77
78
}
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
+ }
78
110
}
79
111
}
You can’t perform that action at this time.
0 commit comments