diff --git a/appveyor.yml b/appveyor.yml index 8f5a9d8294..1b10d99b4a 100644 --- a/appveyor.yml +++ b/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 diff --git a/src/Perspex.SceneGraph/Rect.cs b/src/Perspex.SceneGraph/Rect.cs index 2dba97e764..c3d3a95111 100644 --- a/src/Perspex.SceneGraph/Rect.cs +++ b/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; diff --git a/tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj b/tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj index 7c4daf0867..f76c567f3a 100644 --- a/tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj +++ b/tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj @@ -72,6 +72,7 @@ + @@ -158,4 +159,4 @@ --> - \ No newline at end of file + diff --git a/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs b/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs new file mode 100644 index 0000000000..667e2b4cbb --- /dev/null +++ b/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 + { + 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(); + } + } +} diff --git a/tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs b/tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs index 9ee4e37e3f..625d73e95e 100644 --- a/tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs +++ b/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); } } }