Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#3263 from AvaloniaUI/fixes/styled-test-…
Browse files Browse the repository at this point in the history
…base-classes

Simplify test controls in styling unit tests.
  • Loading branch information
grokys authored Nov 16, 2019
2 parents 9295858 + 24f11bb commit 44d885f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 336 deletions.
85 changes: 4 additions & 81 deletions tests/Avalonia.Styling.UnitTests/SelectorTests_Child.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,89 +81,12 @@ public void Child_Selector_Should_Have_Correct_String_Representation()
Assert.Equal("TestLogical1 > TestLogical3", selector.ToString());
}

public abstract class TestLogical : ILogical, IStyleable
public abstract class TestLogical : Control
{
public TestLogical()
public ILogical LogicalParent
{
Classes = new Classes();
}

public event EventHandler<AvaloniaPropertyChangedEventArgs> PropertyChanged;
public event EventHandler<AvaloniaPropertyChangedEventArgs> InheritablePropertyChanged;
public event EventHandler<LogicalTreeAttachmentEventArgs> AttachedToLogicalTree;
public event EventHandler<LogicalTreeAttachmentEventArgs> DetachedFromLogicalTree;

public Classes Classes { get; }

public string Name { get; set; }

public bool IsAttachedToLogicalTree { get; }

public IAvaloniaReadOnlyList<ILogical> LogicalChildren { get; set; }

public ILogical LogicalParent { get; set; }

public Type StyleKey { get; }

public ITemplatedControl TemplatedParent { get; }

IObservable<IStyleable> IStyleable.StyleDetach { get; }

IAvaloniaReadOnlyList<string> IStyleable.Classes => Classes;

public object GetValue(AvaloniaProperty property)
{
throw new NotImplementedException();
}

public T GetValue<T>(AvaloniaProperty<T> property)
{
throw new NotImplementedException();
}

public void SetValue(AvaloniaProperty property, object value, BindingPriority priority)
{
throw new NotImplementedException();
}

public void SetValue<T>(AvaloniaProperty<T> property, T value, BindingPriority priority = BindingPriority.LocalValue)
{
throw new NotImplementedException();
}

public IDisposable Bind(AvaloniaProperty property, IObservable<object> source, BindingPriority priority)
{
throw new NotImplementedException();
}

public bool IsAnimating(AvaloniaProperty property)
{
throw new NotImplementedException();
}

public bool IsSet(AvaloniaProperty property)
{
throw new NotImplementedException();
}

public IDisposable Bind<T>(AvaloniaProperty<T> property, IObservable<T> source, BindingPriority priority = BindingPriority.LocalValue)
{
throw new NotImplementedException();
}

public void NotifyAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
{
throw new NotImplementedException();
}

public void NotifyDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
{
throw new NotImplementedException();
}

public void NotifyResourcesChanged(ResourcesChangedEventArgs e)
{
throw new NotImplementedException();
get => Parent;
set => ((ISetLogicalParent)this).SetParent(value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Avalonia.Styling.UnitTests/SelectorTests_Class.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void Only_Notifies_When_Result_Changes()
Assert.Equal(new[] { true, false }, result);
}

public class Control1 : TestControlBase
public class Control1 : Control
{
}
}
Expand Down
85 changes: 4 additions & 81 deletions tests/Avalonia.Styling.UnitTests/SelectorTests_Descendent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,89 +111,12 @@ public void Descendant_Selector_Should_Have_Correct_String_Representation()
Assert.Equal("TestLogical1.foo TestLogical3", selector.ToString());
}

public abstract class TestLogical : ILogical, IStyleable
public abstract class TestLogical : Control
{
public TestLogical()
public ILogical LogicalParent
{
Classes = new Classes();
}

public event EventHandler<AvaloniaPropertyChangedEventArgs> PropertyChanged;
public event EventHandler<AvaloniaPropertyChangedEventArgs> InheritablePropertyChanged;
public event EventHandler<LogicalTreeAttachmentEventArgs> AttachedToLogicalTree;
public event EventHandler<LogicalTreeAttachmentEventArgs> DetachedFromLogicalTree;

public Classes Classes { get; }

public string Name { get; set; }

public bool IsAttachedToLogicalTree { get; }

public IAvaloniaReadOnlyList<ILogical> LogicalChildren { get; set; }

public ILogical LogicalParent { get; set; }

public Type StyleKey { get; }

public ITemplatedControl TemplatedParent { get; }

IAvaloniaReadOnlyList<string> IStyleable.Classes => Classes;

IObservable<IStyleable> IStyleable.StyleDetach { get; }

public object GetValue(AvaloniaProperty property)
{
throw new NotImplementedException();
}

public T GetValue<T>(AvaloniaProperty<T> property)
{
throw new NotImplementedException();
}

public void SetValue(AvaloniaProperty property, object value, BindingPriority priority)
{
throw new NotImplementedException();
}

public void SetValue<T>(AvaloniaProperty<T> property, T value, BindingPriority priority = BindingPriority.LocalValue)
{
throw new NotImplementedException();
}

public IDisposable Bind(AvaloniaProperty property, IObservable<object> source, BindingPriority priority = BindingPriority.LocalValue)
{
throw new NotImplementedException();
}

public bool IsAnimating(AvaloniaProperty property)
{
throw new NotImplementedException();
}

public bool IsSet(AvaloniaProperty property)
{
throw new NotImplementedException();
}

public IDisposable Bind<T>(AvaloniaProperty<T> property, IObservable<T> source, BindingPriority priority = BindingPriority.LocalValue)
{
throw new NotImplementedException();
}

public void NotifyAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
{
throw new NotImplementedException();
}

public void NotifyDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
{
throw new NotImplementedException();
}

public void NotifyResourcesChanged(ResourcesChangedEventArgs e)
{
throw new NotImplementedException();
get => Parent;
set => ((ISetLogicalParent)this).SetParent(value);
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Avalonia.Styling.UnitTests/SelectorTests_Name.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.

using Avalonia.Controls;
using Moq;
using Xunit;

Expand Down Expand Up @@ -52,7 +53,7 @@ public void Type_And_Name_Has_Correct_String_Representation()
Assert.Equal("Control1#foo", target.ToString());
}

public class Control1 : TestControlBase
public class Control1 : Control
{
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Avalonia.Styling.UnitTests/SelectorTests_Not.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public void Returns_Correct_TargetType()
Assert.Equal(typeof(Control1), target.TargetType);
}

public class Control1 : TestControlBase
public class Control1 : Control
{
}

public class Control2 : TestControlBase
public class Control2 : Control
{
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/Avalonia.Styling.UnitTests/SelectorTests_OfType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.

using Avalonia.Controls;
using Moq;
using Xunit;

Expand Down Expand Up @@ -44,11 +45,11 @@ public void OfType_Matches_Control_With_TemplatedParent()
Assert.Equal(SelectorMatchResult.AlwaysThisType, target.Match(control).Result);
}

public class Control1 : TestControlBase
public class Control1 : Control
{
}

public class Control2 : TestControlBase
public class Control2 : Control
{
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Avalonia.Styling.UnitTests/SelectorTests_Or.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.

using Avalonia.Controls;
using Xunit;

namespace Avalonia.Styling.UnitTests
Expand Down Expand Up @@ -78,7 +79,7 @@ public void Returns_Common_TargetType()
default(Selector).OfType<Control1>().Class("foo"),
default(Selector).OfType<Control2>().Class("bar"));

Assert.Equal(typeof(TestControlBase), target.TargetType);
Assert.Equal(typeof(Control), target.TargetType);
}

[Fact]
Expand All @@ -91,15 +92,15 @@ public void Returns_Null_TargetType_When_A_Selector_Has_No_TargetType()
Assert.Equal(null, target.TargetType);
}

public class Control1 : TestControlBase
public class Control1 : Control
{
}

public class Control2 : TestControlBase
public class Control2 : Control
{
}

public class Control3 : TestControlBase
public class Control3 : Control
{
}
}
Expand Down
83 changes: 0 additions & 83 deletions tests/Avalonia.Styling.UnitTests/TestControlBase.cs

This file was deleted.

Loading

0 comments on commit 44d885f

Please sign in to comment.