Browse Source

Merge branch 'master' into scenegraph

scenegraph-after-breakage
Steven Kirk 10 years ago
parent
commit
11fd0fb492
  1. 2
      tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj
  2. 42
      tests/Avalonia.Visuals.UnitTests/RectTests.cs
  3. 26
      tests/Avalonia.Visuals.UnitTests/SizeTests.cs

2
tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj

@ -80,6 +80,8 @@
<Compile Include="Media\FormattedTextTests.cs" />
<Compile Include="Media\PathMarkupParserTests.cs" />
<Compile Include="RelativeRectComparer.cs" />
<Compile Include="SizeTests.cs" />
<Compile Include="RectTests.cs" />
<Compile Include="RelativeRectTests.cs" />
<Compile Include="Rendering\DeferredRendererTests.cs" />
<Compile Include="Rendering\SceneGraph\DeferredDrawingContextImplTests.cs" />

42
tests/Avalonia.Visuals.UnitTests/RectTests.cs

@ -0,0 +1,42 @@
// 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 Xunit;
namespace Avalonia.Visuals.UnitTests
{
public class RectTests
{
[Fact]
public void Union_Should_Return_Correct_Value_For_Intersecting_Rects()
{
var result = new Rect(0, 0, 100, 100).Union(new Rect(50, 50, 100, 100));
Assert.Equal(new Rect(0, 0, 150, 150), result);
}
[Fact]
public void Union_Should_Return_Correct_Value_For_NonIntersecting_Rects()
{
var result = new Rect(0, 0, 100, 100).Union(new Rect(150, 150, 100, 100));
Assert.Equal(new Rect(0, 0, 250, 250), result);
}
[Fact]
public void Union_Should_Ignore_Empty_This_rect()
{
var result = new Rect(0, 0, 0, 0).Union(new Rect(150, 150, 100, 100));
Assert.Equal(new Rect(150, 150, 100, 100), result);
}
[Fact]
public void Union_Should_Ignore_Empty_Other_rect()
{
var result = new Rect(0, 0, 100, 100).Union(new Rect(150, 150, 0, 0));
Assert.Equal(new Rect(0, 0, 100, 100), result);
}
}
}

26
tests/Avalonia.Visuals.UnitTests/SizeTests.cs

@ -0,0 +1,26 @@
// 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 Xunit;
namespace Avalonia.Visuals.UnitTests
{
public class SizeTests
{
[Fact]
public void Should_Produce_Correct_Aspect_Ratio()
{
var result = new Size(3, 2).AspectRatio;
Assert.Equal(1.5, result);
}
[Fact]
public void Dividing_Should_Produce_Scaling_Factor()
{
var result = new Size(15, 10) / new Size(5, 5);
Assert.Equal(new Vector(3, 2), result);
}
}
}
Loading…
Cancel
Save