A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

349 lines
9.9 KiB

// -----------------------------------------------------------------------
// <copyright file="BorderTests.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Direct2D1.RenderTests.Controls
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Perspex.Controls;
using Perspex.Layout;
using Perspex.Media;
[TestClass]
public class BorderTests : TestBase
{
public BorderTests()
: base(@"Controls\Border")
{
}
[TestMethod]
public void Border_1px_Border()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 1,
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_2px_Border()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Fill()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
Background = Brushes.Red,
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Brush_Offsets_Content()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new Border
{
Background = Brushes.Red,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Padding_Offsets_Content()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Padding = new Thickness(2),
Content = new Border
{
Background = Brushes.Red,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Margin_Offsets_Content()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new Border
{
Background = Brushes.Red,
Margin = new Thickness(2),
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Centers_Content_Horizontally()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new TextBlock
{
Text = "Foo",
Background = Brushes.Red,
HorizontalAlignment = HorizontalAlignment.Center,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Centers_Content_Vertically()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new TextBlock
{
Text = "Foo",
Background = Brushes.Red,
VerticalAlignment = VerticalAlignment.Center,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Stretches_Content_Horizontally()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new TextBlock
{
Text = "Foo",
Background = Brushes.Red,
HorizontalAlignment = HorizontalAlignment.Stretch,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Stretches_Content_Vertically()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new TextBlock
{
Text = "Foo",
Background = Brushes.Red,
VerticalAlignment = VerticalAlignment.Stretch,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Left_Aligns_Content()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new TextBlock
{
Text = "Foo",
Background = Brushes.Red,
HorizontalAlignment = HorizontalAlignment.Left,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Right_Aligns_Content()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new TextBlock
{
Text = "Foo",
Background = Brushes.Red,
HorizontalAlignment = HorizontalAlignment.Right,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Top_Aligns_Content()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new TextBlock
{
Text = "Foo",
Background = Brushes.Red,
VerticalAlignment = VerticalAlignment.Top,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Bottom_Aligns_Content()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new TextBlock
{
Text = "Foo",
Background = Brushes.Red,
VerticalAlignment = VerticalAlignment.Bottom,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
}
}