void Ex01()
 {
     Given("a property whose value is null", () => Property = new ObservableProperty <string?>(null));
     Given("a BoundProperty that binds a given property", () => BoundProperty = BoundProperty <string?> .By(Property));
     When("the BoundProperty value changing handler is added", () => BoundProperty.PropertyValueChanging += (_, e) =>
     {
         OldPropertyValue = e.OldValue;
         NewPropertyValue = e.NewValue;
     });
     When("the value of the property is changed", () => Property.Value = "Changed");
     Then("the old value of the property value changing handler should be the previous value", () => OldPropertyValue == null);
     Then("the new value of the property value changing handler should be the changed value", () => NewPropertyValue == "Changed");
     Then("the value of the BoundProperty should be the changed value", () => Property.Value == "Changed");
 }
Esempio n. 2
0
 void Ex02()
 {
     Given("a property whose value is not null", () => Property = ObservableProperty <string?> .Of("Test"));
     Given("a BoundProperty that binds a given property", () => BoundProperty = BoundProperty <string?> .By(Property));
     When("the property value changing handler in which the value changing is canceled is added", () => Property.PropertyValueChanging += (_, e) => e.Disable());
     When("the property value changed handler is added", () => Property.PropertyValueChanged += (_, e) =>
     {
         OldPropertyValue = e.OldValue;
         NewPropertyValue = e.NewValue;
     });
     When("the value of the property is changed", () => Property.Value = "Changed");
     Then("the property changed event handler should not be called", () => OldPropertyValue == null && NewPropertyValue == null);
     Then("the value of the BoundProperty should not be changed", () => BoundProperty.Value == "Test");
 }