void Ex03() { Given("a property whose value type is int", () => Property4 = ObservableProperty <int> .Of(1)); Given("a property whose value type is string", () => Property5 = ObservableProperty <string> .Of("#")); Given("a property whose value type is bool", () => Property6 = ObservableProperty <bool> .Of(false)); When("the property binds the given three properties with a converter", () => Property.Bind( context => context.GetValueAt <bool>(2) ? $"[{context.GetValueAt<string>(1)}{context.GetValueAt<int>(0)}]" : $"{context.GetValueAt<string>(1)}{context.GetValueAt<int>(0)}", Property4, Property5, Property6 ) ); Then("the value of the property should be the converted value", () => Property.Value == "#1"); Then("the value of the first property should not be changed", () => Property4.Value == 1); Then("the value of the second property should not be changed", () => Property5.Value == "#"); Then("the value of the third property should not be changed", () => Property6.Value == false); When("the value of the first property is changed", () => Property4.Value = 7); Then("the value of the property should be the changed value that is converted", () => Property.Value == "#7"); Then("the value of the first property should be the changed value", () => Property4.Value == 7); Then("the value of the second property should not be changed", () => Property5.Value == "#"); Then("the value of the third property should not be changed", () => Property6.Value == false); When("the value of the second property is changed", () => Property5.Value = "## "); Then("the value of the property should be the changed value that is converted", () => Property.Value == "## 7"); Then("the value of the first property should not be changed", () => Property4.Value == 7); Then("the value of the second property should be the changed value", () => Property5.Value == "## "); Then("the value of the third property should not be changed", () => Property6.Value == false); When("the value of the third property is changed", () => Property6.Value = true); Then("the value of the property should be the changed value that is converted", () => Property.Value == "[## 7]"); Then("the value of the first property should not be changed", () => Property4.Value == 7); Then("the value of the second property should not be changed", () => Property5.Value == "## "); Then("the value of the third property should be the changed value", () => Property6.Value); }
void Ex02() { Given("a property whose value type is int", () => Property1 = ObservableProperty <int> .Of(1)); Given("a property whose value type is int", () => Property2 = ObservableProperty <int> .Of(2)); Given("a property whose value type is int", () => Property3 = ObservableProperty <int> .Of(3)); When("the property binds the given three properties with a converter that converts to the sum of these values", () => Property.Bind(context => (context.GetValueAt <int>(0) + context.GetValueAt <int>(1) + context.GetValueAt <int>(2)).ToString(), Property1, Property2, Property3) ); Then("the value of the property should be the changed value", () => Property.Value == "6"); Then("the value of the first property should not be changed", () => Property1.Value == 1); Then("the value of the second property should not be changed", () => Property2.Value == 2); Then("the value of the third property should not be changed", () => Property3.Value == 3); When("the property unbinds", () => Property.Unbind()); When("the value of the first property is changed", () => Property1.Value = 7); Then("the value of the property should not be changed", () => Property.Value == "6"); Then("the value of the first property should be the changed value", () => Property1.Value == 7); Then("the value of the second property should not be changed", () => Property2.Value == 2); Then("the value of the third property should not be changed", () => Property3.Value == 3); When("the value of the second property is changed", () => Property2.Value = 8); Then("the value of the property should not be changed", () => Property.Value == "6"); Then("the value of the first property should not be changed", () => Property1.Value == 7); Then("the value of the second property should be the changed value", () => Property2.Value == 8); Then("the value of the third property should not be changed", () => Property3.Value == 3); When("the value of the third property is changed", () => Property3.Value = 9); Then("the value of the property should not be changed", () => Property.Value == "6"); Then("the value of the first property should not be changed", () => Property1.Value == 7); Then("the value of the second property should not be changed", () => Property2.Value == 8); Then("the value of the third property should be the changed value", () => Property3.Value == 9); }
void Ex05() { Given("a property whose value type is int", () => Property1 = ObservableProperty <int> .Of(1)); Given("a property whose value type is int", () => Property2 = ObservableProperty <int> .Of(2)); Given("a property whose value type is int", () => Property3 = ObservableProperty <int> .Of(3)); When("the property binds the given three properties with a converter that is null", () => Property.Bind(null, Property1, Property2, Property3)); Then <ArgumentNullException>($"{typeof(ArgumentNullException)} should be thrown"); }
void Ex02() { Given("a property whose value is not null", () => Property = ObservableProperty <string> .Of("Test")); When("the property value changing handler in which the value changing is canceled is added", () => Property.PropertyValueChanging += (s, e) => e.Disable()); When("the property value changed handler is added", () => Property.PropertyValueChanged += (s, 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 property should not be changed", () => Property.Value == "Test"); }
void Ex02() { Given("a property whose value is not null", () => Property = ObservableProperty <string> .Of("Test")); When("the property value changing handler in which the value changing is canceled is added", () => Property.PropertyValueChanging += (s, e) => { OldPropertyValue = e.OldValue; NewPropertyValue = e.NewValue; e.Disable(); }); 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 == "Test"); Then("the new value of the property value changing handler should be the changed value", () => NewPropertyValue == "Changed"); Then("the value of the property should not be changed", () => Property.Value == "Test"); }
void Ex04() { Given("a property whose value type is int", () => Property1 = ObservableProperty <int> .Of(1)); Given("a property whose value type is int", () => Property2 = ObservableProperty <int> .Of(2)); Given("a property whose value type is int", () => Property3 = ObservableProperty <int> .Of(3)); When("the property binds the given three properties with a converter that converts to the sum of these values", () => Property.Bind(context => (context.GetValueAt <int>(0) + context.GetValueAt <int>(1) + context.GetValueAt <int>(2)).ToString(), Property1, Property2, Property3) ); When("the property binds another properties with a converter", () => Property.Bind( context => (context.GetValueAt <int>(0) + context.GetValueAt <int>(1) + context.GetValueAt <int>(2)).ToString(), ObservableProperty <int> .Of(4), ObservableProperty <int> .Of(5), ObservableProperty <int> .Of(6) ) ); Then <InvalidOperationException>($"{typeof(InvalidOperationException)} should be thrown"); }
public BoundPropertySpec_Binding_OneWayWithConverter() { Property1 = BoundProperty <string> .Of("Test1"); Property2 = ObservableProperty <int> .Of(3); }
public ObservablePropertySpec_Binding_MultiBinding() { Property = ObservableProperty <string> .Of("Test1"); }
void Ex03() { When("the property1 binds the property2 as two way binding with converters", () => Property1.BindTwoWay(Property2, value => value.ToString(), int.Parse)); When("the property1 binds another property as two way binding with converters", () => Property1.BindTwoWay(ObservableProperty <int> .Of(8), value => value.ToString(), int.Parse)); Then <InvalidOperationException>($"{typeof(InvalidOperationException)} should be thrown"); }
public ObservablePropertySpec_Binding_TwoWay() { Property1 = ObservableProperty <string> .Of("Test1"); Property2 = ObservableProperty <string> .Of("Test2"); }
void CreateObservablePropertyOf(string value, bool successPropertyChangedRaisedAtAnyPropertyNames = false) { Property = ObservableProperty <string> .Of(value); Property.PropertyChanged += (s, e) => PropertyChangedRaised = successPropertyChangedRaisedAtAnyPropertyNames || e.PropertyName == "Value"; }
void Ex03() => Expect("the value of the property should be the specified value", () => ObservableProperty <string> .Of("Test").Value == "Test");
void Ex03() { When("the property1 binds the property2 with a converter", () => Property1.Bind(Property2, value => value.ToString())); When("the property1 binds another property with a converter", () => Property1.Bind(ObservableProperty <int> .Of(7), value => value.ToString())); Then <InvalidOperationException>($"{typeof(InvalidOperationException)} should be thrown"); }
public ObservablePropertySpec_Binding_TwoWayWithConverter() { Property1 = ObservableProperty <string> .Of("8"); Property2 = ObservableProperty <int> .Of(3); }
void Ex04() { When("the property1 binds the property2 as two way binding", () => Property1.BindTwoWay(Property2)); When("the property1 binds another property as two way binding", () => Property1.BindTwoWay(ObservableProperty <string> .Of("Test"))); Then <InvalidOperationException>($"{typeof(InvalidOperationException)} should be thrown"); }
void Ex03() { When("the property1 bind the property2", () => Property1.Bind(Property2)); When("the property1 binds another property", () => Property1.Bind(ObservableProperty<string>.Of("Test"))); Then<InvalidOperationException>($"{typeof(InvalidOperationException)} should be thrown"); }
public BoundPropertySpec_Binding_OneWay() { Property1 = BoundProperty<string>.Of("Test1"); Property2 = ObservableProperty<string>.Of("Test2"); }