예제 #1
0
 void SetValue <T>(T value, ObservableProperty <T> property, BoundProperty <T> boundProperty)
 {
     ErrorsChangedRaised          = false;
     boundProperty.ErrorsChanged += ErrorsChangedVerificationHandler;
     property.Value = value;
     boundProperty.ErrorsChanged -= ErrorsChangedVerificationHandler;
 }
예제 #2
0
 void AssertNoValidationError <T>(BoundProperty <T> property)
 {
     Then("the Error property should be empty", () => property.Error == string.Empty);
     Then("the value of 'Value' of the indexer should be empty", () => ((IDataErrorInfo)property)["Value"] == string.Empty);
     Then("the Errors property should be empty", () => !property.Errors.Any());
     Then("the HasErrors property should be false", () => !property.HasErrors);
     Then("the value of the GetErrors whose parameter is 'Value' should be empty", () => !((INotifyDataErrorInfo)property).GetErrors("Value").Cast <string>().Any());
 }
예제 #3
0
        public BoundPropertySpec_Validation()
        {
            PropertyNotAttributedValidation    = new BoundProperty <string>().Bind(Property);
            PropertyAttributedValidation       = new BoundProperty <string>().Bind(Property);
            PropertyAttributedMultiValidations = new BoundProperty <string>().Bind(Property);
            RequiredProperty = new BoundProperty <string>().Bind(Property);
            LocalizablePropertyAttributedValidation = new BoundProperty <string>().Bind(Property);

            ErrorsChangedVerificationHandler = (s, e) => ErrorsChangedRaised = true;
        }
예제 #4
0
        void AssertValidationError <T>(BoundProperty <T> property, params string[] messages)
        {
            var expectedMessage = string.Join(Environment.NewLine, messages);

            Then("the Error property should be the specified message", () => property.Error == expectedMessage);
            Then("the value of 'Value' of the indexer should be the specified message", () => ((IDataErrorInfo)property)["Value"] == expectedMessage);
            Then("the Errors property should be the specified message", () => property.Errors.SequenceEqual(messages));
            Then("the HasErrors property should be true", () => property.HasErrors);
            Then("the value of the GetErrors whose parameter is 'Value' should be the specified message", () =>
                 ((INotifyDataErrorInfo)property).GetErrors("Value").Cast <string>().SequenceEqual(messages)
                 );
        }
 void Ex03() => Expect("the value of the property should be the specified value", () => BoundProperty <string> .Of("Test").Value == "Test");
 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> .Of(null).Bind(Property));
     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 BoundProperty should not be changed", () => BoundProperty.Value == "Test");
 }
 void Ex01()
 {
     Given("a property whose value is null", () => Property = new ObservableProperty <string>());
     Given("a BoundProperty that binds a given property", () => BoundProperty = BoundProperty <string> .Of(null).Bind(Property));
     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 old value of the property value changed handler should be the previous value", () => OldPropertyValue == null);
     Then("the new value of the property value changed handler should be the changed value", () => NewPropertyValue == "Changed");
     Then("the value of the BoundProperty should be the changed value", () => BoundProperty.Value == "Changed");
 }
예제 #8
0
 /// <summary>
 /// Converts the specified value to the bound property.
 /// </summary>
 /// <typeparam name="T">The type of the property value.</typeparam>
 /// <param name="target">The object that is converted to the bound property.</param>
 /// <returns>The instance of the <see cref="BoundProperty{T}"/> class.</returns>
 public static BoundProperty <T> ToBoundProperty <T>(this T target) => BoundProperty <T> .Of(target);
        public BoundPropertySpec_Binding_OneWayWithConverter()
        {
            Property1 = BoundProperty <string> .Of("Test1");

            Property2 = ObservableProperty <int> .Of(3);
        }
 public BoundProperty_Spec_Binding_MultiBinding()
 {
     Property = BoundProperty <string> .Of("Test1");
 }
 public BoundPropertySpec_Binding_OneWay()
 {
     Property1 = BoundProperty<string>.Of("Test1");
     Property2 = ObservableProperty<string>.Of("Test2");
 }
예제 #12
0
        void Ex01()
        {
            When("the delay of the property value change of the BoundProperty is enabled", () => BoundProperty.EnableDelayValueChange(TimeSpan.FromMilliseconds(100)));
            When("the property value is changed", () => Property.Value = "Changed");
            Then("the BoundProperty value should not be changed", () => BoundProperty.Value == "Test");
            When("to wait for the delay time", async() => await Task.Delay(200));
            Then("the BoundProperty value should be changed", () => BoundProperty.Value == "Changed");

            When("the delay of the property value change of the BoundProperty is disabled", () => BoundProperty.DisableDelayValueChange());
            When("the property value is changed", () => Property.Value = "Modified");
            Then("the BoundProperty value should be changed", () => BoundProperty.Value == "Modified");
        }
예제 #13
0
 public BoundPropertySpec_DelayValueChange()
 {
     BoundProperty.Bind(Property);
 }