@@ -1039,6 +1039,59 @@ void SelectionModel_SelectionChanged(SelectionModel sender, SelectionModelSelect
1039
1039
}
1040
1040
}
1041
1041
1042
+ [ TestMethod ]
1043
+ public void AlreadyDeselectedDoesNotRaiseEvent ( )
1044
+ {
1045
+ var testName = "Deselect(int32 index), single select" ;
1046
+
1047
+ RunOnUIThread . Execute ( ( ) =>
1048
+ {
1049
+ var list = Enumerable . Range ( 0 , 10 ) . ToList ( ) ;
1050
+
1051
+ var selectionModel = new SelectionModel ( ) {
1052
+ Source = list ,
1053
+ SingleSelect = true
1054
+ } ;
1055
+
1056
+ // Single select index
1057
+ selectionModel . SelectionChanged += SelectionModel_SelectionChanged ;
1058
+ selectionModel . Deselect ( 0 ) ;
1059
+
1060
+ selectionModel = new SelectionModel ( ) {
1061
+ Source = list ,
1062
+ SingleSelect = true
1063
+ } ;
1064
+ // Single select indexpath
1065
+ testName = "DeselectAt(IndexPath index), single select" ;
1066
+ selectionModel . SelectionChanged += SelectionModel_SelectionChanged ;
1067
+ selectionModel . DeselectAt ( IndexPath . CreateFrom ( 1 ) ) ;
1068
+
1069
+ // multi select index
1070
+ selectionModel = new SelectionModel ( ) {
1071
+ Source = list
1072
+ } ;
1073
+ testName = "Deselect(int32 index), multiselect" ;
1074
+ selectionModel . SelectionChanged += SelectionModel_SelectionChanged ;
1075
+ selectionModel . Deselect ( 1 ) ;
1076
+ selectionModel . Deselect ( 2 ) ;
1077
+
1078
+ selectionModel = new SelectionModel ( ) {
1079
+ Source = list
1080
+ } ;
1081
+
1082
+ // multi select indexpath
1083
+ testName = "DeselectAt(IndexPath index), multiselect" ;
1084
+ selectionModel . SelectionChanged += SelectionModel_SelectionChanged ;
1085
+ selectionModel . DeselectAt ( IndexPath . CreateFrom ( 1 ) ) ;
1086
+ selectionModel . DeselectAt ( IndexPath . CreateFrom ( 2 ) ) ;
1087
+ } ) ;
1088
+
1089
+ void SelectionModel_SelectionChanged ( SelectionModel sender , SelectionModelSelectionChangedEventArgs args )
1090
+ {
1091
+ throw new Exception ( "SelectionChangedEvent was raised, but shouldn't have been raised as selection did not change. Tested method: " + testName ) ;
1092
+ }
1093
+ }
1094
+
1042
1095
private void Select ( SelectionModel manager , int index , bool select )
1043
1096
{
1044
1097
Log . Comment ( ( select ? "Selecting " : "DeSelecting " ) + index ) ;
0 commit comments