示例#1
0
    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);
    }
示例#2
0
    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);
    }
示例#3
0
 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 += (_, 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 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 += (_, 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");
    }
示例#5
0
 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");
 }
示例#6
0
    void CreateObservablePropertyOf(string?value, bool successPropertyChangedRaisedAtAnyPropertyNames = false)
    {
        Property = ObservableProperty <string?> .Of(value);

        Property.PropertyChanged += (_, e) => PropertyChangedRaised = successPropertyChangedRaisedAtAnyPropertyNames || e.PropertyName == "Value";
    }
示例#7
0
 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");
 }
示例#8
0
    public ObservablePropertySpec_Binding_TwoWay()
    {
        Property1 = ObservableProperty <string> .Of("Test1");

        Property2 = ObservableProperty <string> .Of("Test2");
    }
 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");
 }
 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_OneWayWithConverter()
    {
        Property1 = ObservableProperty <string> .Of("Test1");

        Property2 = ObservableProperty <int> .Of(3);
    }
 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 BoundPropertySpec_Binding_OneWay()
    {
        Property1 = BoundProperty <string> .Of("Test1");

        Property2 = ObservableProperty <string> .Of("Test2");
    }
示例#14
0
 /// <summary>
 /// Converts the specified value to the observable property.
 /// </summary>
 /// <typeparam name="T">The type of the property value.</typeparam>
 /// <param name="target">The object that is converted to the observable property.</param>
 /// <returns>The instance of the <see cref="ObservableProperty{T}"/> class.</returns>
 public static ObservableProperty <T> ToObservableProperty <T>(this T target) => ObservableProperty <T> .Of(target);
示例#15
0
 public ObservablePropertySpec_Binding_MultiBinding()
 {
     Property = ObservableProperty <string> .Of("Test1");
 }