From fda6a892fbacdebeb7c7466c1f4633990fb5d984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sun, 19 Mar 2017 20:12:45 +0100 Subject: [PATCH] Removed unused cs file File was not included in old csproj project --- .../Data/BindingTests_Validation.cs | 126 ------------------ 1 file changed, 126 deletions(-) delete mode 100644 tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Validation.cs diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Validation.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Validation.cs deleted file mode 100644 index 8759cb42c5..0000000000 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Validation.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Avalonia.Controls; -using Avalonia.Data; -using Avalonia.Markup.Xaml.Data; -using Avalonia.UnitTests; -using Xunit; - -namespace Avalonia.Markup.Xaml.UnitTests.Data -{ - public class BindingTests_Validation - { - [Fact] - public void Non_Validated_Property_Does_Not_Receive_BindingNotifications() - { - var source = new ValidationTestModel { MustBePositive = 5 }; - var target = new TestControl - { - DataContext = source, - [!TestControl.NonValidatedProperty] = new Binding(nameof(source.MustBePositive)), - }; - - Assert.Empty(target.Notifications); - } - - [Fact] - public void Validated_Direct_Property_Receives_BindingNotifications() - { - var source = new ValidationTestModel { MustBePositive = 5 }; - var target = new TestControl - { - DataContext = source, - }; - - target.Bind( - TestControl.ValidatedDirectProperty, - new Binding(nameof(source.MustBePositive), BindingMode.TwoWay)); - - target.ValidatedDirect = 6; - target.ValidatedDirect = -1; - target.ValidatedDirect = 7; - - Assert.Equal( - new[] - { - new BindingNotification(5), - new BindingNotification(6), - new BindingNotification(new ArgumentOutOfRangeException("value"), BindingErrorType.DataValidationError), - new BindingNotification(7), - }, - target.Notifications.AsEnumerable()); - } - - private class TestControl : Control - { - public static readonly StyledProperty NonValidatedProperty = - AvaloniaProperty.Register( - nameof(Validated), - enableDataValidation: false); - - public static readonly StyledProperty ValidatedProperty = - AvaloniaProperty.Register( - nameof(Validated), - enableDataValidation: true); - - public static readonly DirectProperty ValidatedDirectProperty = - AvaloniaProperty.RegisterDirect( - nameof(Validated), - o => o.ValidatedDirect, - (o, v) => o.ValidatedDirect = v, - enableDataValidation: true); - - private int _direct; - - public int NonValidated - { - get { return GetValue(NonValidatedProperty); } - set { SetValue(NonValidatedProperty, value); } - } - - public int Validated - { - get { return GetValue(ValidatedProperty); } - set { SetValue(ValidatedProperty, value); } - } - - public int ValidatedDirect - { - get { return _direct; } - set { SetAndRaise(ValidatedDirectProperty, ref _direct, value); } - } - - public IList Notifications { get; } = new List(); - - protected override void BindingNotificationReceived(AvaloniaProperty property, BindingNotification notification) - { - Notifications.Add(notification); - } - } - - private class ValidationTestModel : NotifyingBase - { - private int _mustBePositive; - - public int MustBePositive - { - get { return _mustBePositive; } - set - { - if (value <= 0) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - if (_mustBePositive != value) - { - _mustBePositive = value; - RaisePropertyChanged(); - } - } - } - } - } -}