2
// EditorCompareWidgetBaseTest.cs
5
// IBBoard <dev@ibboard.co.uk>
7
// Copyright (c) 2011 IBBoard
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
using NUnit.Framework;
28
using Mono.TextEditor.Utils;
31
namespace MonoDevelop.VersionControl.Views
34
public class EditorCompareWidgetBaseTest
36
private delegate void ColorAssertion (Color color);
39
public void TestRemovalLineColorIsRed ()
41
CheckCombinationsAreColor (new Hunk (0, 0, 1, 0), AssertIsRed);
42
CheckCombinationsAreColor (new Hunk (0, 0, 2, 0), AssertIsRed);
46
public void TestAdditionLineColorIsGreen ()
48
CheckCombinationsAreColor (new Hunk (0, 0, 0, 1), AssertIsGreen);
49
CheckCombinationsAreColor (new Hunk (0, 0, 0, 2), AssertIsGreen);
53
public void TestAdditionAndRemovalLineColorIsGreen ()
55
CheckCombinationsAreColor (new Hunk (0, 0, 1, 1), AssertIsBlue);
56
CheckCombinationsAreColor (new Hunk (0, 0, 2, 2), AssertIsBlue);
57
CheckCombinationsAreColor (new Hunk (0, 0, 1, 2), AssertIsBlue);
58
CheckCombinationsAreColor (new Hunk (0, 0, 2, 1), AssertIsBlue);
62
public void TestDarkColorsAreDarker ()
64
CheckDarkColoursAreDarker (new Hunk (0, 0, 1, 0));
65
CheckDarkColoursAreDarker (new Hunk (0, 0, 0, 1));
66
CheckDarkColoursAreDarker (new Hunk (0, 0, 1, 1));
69
private void CheckCombinationsAreColor (Hunk hunk, ColorAssertion assertion)
71
assertion (GetColor (hunk, true, true));
72
assertion (GetColor (hunk, true, false));
73
assertion (GetColor (hunk, false, true));
74
assertion (GetColor (hunk, false, false));
77
private Color GetColor (Hunk hunk, bool removeSide, bool dark)
79
return EditorCompareWidgetBase.GetColor (hunk, removeSide, dark, 1.0);
82
private void AssertIsRed (Color color)
84
Assert.Greater (color.R, color.G);
85
Assert.Greater (color.R, color.B);
88
private void AssertIsGreen (Color color)
90
Assert.Greater (color.G, color.R);
91
Assert.Greater (color.G, color.B);
94
private void AssertIsBlue (Color color)
96
Assert.Greater (color.B, color.G);
97
Assert.Greater (color.B, color.R);
100
private void CheckDarkColoursAreDarker (Hunk hunk)
102
Color dark = GetColor (hunk, true, true);
103
Color light = GetColor (hunk, true, false);
104
Assert.Less (dark.R, light.R);
105
Assert.Less (dark.B, light.B);
106
Assert.Less (dark.G, light.G);