Browse Source

Merge pull request #303 from wieslawsoltes/ci

Fix appveyor builds and failing tests
pull/308/head
Steven Kirk 11 years ago
parent
commit
a609e6cc98
  1. 8
      appveyor.yml
  2. 3
      src/Perspex.SceneGraph/Rect.cs
  3. 3
      tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj
  4. 25
      tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs
  5. 6
      tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs

8
appveyor.yml

@ -9,8 +9,12 @@ environment:
secure: XOgD5bJUKNOS2kDDgb+affS4pDcslxALh+xvvnr1Koy0PjXlhILsBdNhxRe0KcNm
install:
- appveyor DownloadFile http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.26.msi
- start /wait msiexec /i gtk-sharp-2.12.26.msi /qn /norestart
- if not exist gtk-sharp-2.12.26.msi appveyor DownloadFile http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.26.msi
- msiexec /i gtk-sharp-2.12.26.msi /qn /norestart
- cmd: set PATH=%programfiles(x86)%\GtkSharp\2.12\bin\;%PATH%
cache:
- gtk-sharp-2.12.26.msi
configuration:
- Release

3
src/Perspex.SceneGraph/Rect.cs

@ -297,7 +297,8 @@ namespace Perspex
{
if (obj is Rect)
{
return this == (Rect)obj;
var other = (Rect)obj;
return Position == other.Position && Size == other.Size;
}
return false;

3
tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj

@ -72,6 +72,7 @@
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="RelativeRectComparer.cs" />
<Compile Include="RelativeRectTests.cs" />
<Compile Include="ThicknessTests.cs" />
<Compile Include="Media\BrushTests.cs" />
@ -158,4 +159,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

25
tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs

@ -0,0 +1,25 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
namespace Perspex.SceneGraph.UnitTests
{
public class RelativeRectComparer : IEqualityComparer<RelativeRect>
{
public bool Equals(RelativeRect a, RelativeRect b)
{
return a.Unit == b.Unit &&
Math.Round(a.Rect.X, 3) == Math.Round(b.Rect.X, 3) &&
Math.Round(a.Rect.Y, 3) == Math.Round(b.Rect.Y, 3) &&
Math.Round(a.Rect.Width, 3) == Math.Round(b.Rect.Width, 3) &&
Math.Round(a.Rect.Height, 3) == Math.Round(b.Rect.Height, 3);
}
public int GetHashCode(RelativeRect obj)
{
throw new NotImplementedException();
}
}
}

6
tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs

@ -8,12 +8,14 @@ namespace Perspex.SceneGraph.UnitTests
{
public class RelativeRectTests
{
private static readonly RelativeRectComparer Compare = new RelativeRectComparer();
[Fact]
public void Parse_Should_Accept_Absolute_Value()
{
var result = RelativeRect.Parse("4,5,50,60", CultureInfo.InvariantCulture);
Assert.Equal(new RelativeRect(4, 5, 50, 60, RelativeUnit.Absolute), result);
Assert.Equal(new RelativeRect(4, 5, 50, 60, RelativeUnit.Absolute), result, Compare);
}
[Fact]
@ -21,7 +23,7 @@ namespace Perspex.SceneGraph.UnitTests
{
var result = RelativeRect.Parse("10%, 20%, 40%, 70%", CultureInfo.InvariantCulture);
Assert.Equal(new RelativeRect(0.1, 0.2, 0.4, 0.7, RelativeUnit.Relative), result);
Assert.Equal(new RelativeRect(0.1, 0.2, 0.4, 0.7, RelativeUnit.Relative), result, Compare);
}
}
}

Loading…
Cancel
Save