You've already forked linux-packaging-mono
Imported Upstream version 3.8.0
Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
This commit is contained in:
@@ -639,6 +639,62 @@ namespace MonoTests.System.ComponentModel
|
||||
|
||||
Assert.AreEqual (1, count, "1");
|
||||
}
|
||||
|
||||
private class Person : INotifyPropertyChanged
|
||||
{
|
||||
private string _lastName;
|
||||
private string _firstName;
|
||||
|
||||
public string FirstName {
|
||||
get { return _firstName; }
|
||||
set {
|
||||
_firstName = value;
|
||||
OnPropertyChanged ("FirstName"); // string matches property name
|
||||
}
|
||||
}
|
||||
|
||||
public string LastName {
|
||||
get { return _lastName; }
|
||||
set {
|
||||
_lastName = value;
|
||||
OnPropertyChanged ("Apepe"); // string doesn't match property name
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged (string propertyName = null)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
if (handler != null)
|
||||
handler (this, new PropertyChangedEventArgs (propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
[Test] // https://bugzilla.xamarin.com/show_bug.cgi?id=20672
|
||||
public void Bug20672 ()
|
||||
{
|
||||
string changedPropertyName = string.Empty;
|
||||
bool isEventRaised = false;
|
||||
bool? hasPropertyDescriptor = false;
|
||||
|
||||
var persons = new BindingList<Person>();
|
||||
persons.Add (new Person() { FirstName = "Stefaan", LastName = "de Vogelaere" });
|
||||
persons.Add (new Person() { FirstName = "Christophe", LastName = "De Langhe" });
|
||||
persons.ListChanged += (object sender, ListChangedEventArgs e) => {
|
||||
isEventRaised = true;
|
||||
hasPropertyDescriptor = e.PropertyDescriptor != null;
|
||||
};
|
||||
|
||||
//if the OnPropertyChanged string matches a valid property name, PropertyDescriptor should be generated
|
||||
persons[0].FirstName = "Stefan";
|
||||
Assert.IsTrue (isEventRaised);
|
||||
Assert.IsTrue ((bool) hasPropertyDescriptor, "#1");
|
||||
|
||||
//if the OnPropertyChanged string doesn't match a valid property name, no PropertyDescriptor should be generated
|
||||
persons[0].LastName = "de le Vulu";
|
||||
Assert.IsFalse ((bool) hasPropertyDescriptor, "#2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user