diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2017-08-16 16:32:08 +0300 |
---|---|---|
committer | Lluis Sanchez <llsan@microsoft.com> | 2017-08-16 16:32:08 +0300 |
commit | f69333a14733a898ebce5c6972975f91f1d75b76 (patch) | |
tree | cbbae627cb65cf1b077061e8ff386757c89d78fe /main/src/addins/VersionControl | |
parent | 0568efa74b2effc064b0d80f9f31b743a538bac3 (diff) |
Reorganize unit tests
The UnitTests projects used to have a mix of tests for several assemblies.
This patch reorganizes the tests in several projects that target only
one assembly (for most cases) and have only the dependencies they need
to build.
Tests for MonoDevelop.Core have been moved to a new MonoDevelop.Core.Tests
project.
C# tests have been moved to MonoDevelop.CSharpBinding.Tests.
Other tests have been moved to Ide.Tests, which has been renamed to
MonoDevelop.Ide.Tests. This may require further reorganization.
MonoDevelop.Refactoring tests has been removed since now they are part
of Roslyn.
Diffstat (limited to 'main/src/addins/VersionControl')
2 files changed, 119 insertions, 0 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/EditorCompareWidgetBaseTest.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/EditorCompareWidgetBaseTest.cs new file mode 100644 index 0000000000..3449bffa7a --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/EditorCompareWidgetBaseTest.cs @@ -0,0 +1,110 @@ +// +// EditorCompareWidgetBaseTest.cs +// +// Author: +// IBBoard <dev@ibboard.co.uk> +// +// Copyright (c) 2011 IBBoard +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using NUnit.Framework; +using Mono.TextEditor.Utils; +using Cairo; + +namespace MonoDevelop.VersionControl.Views +{ + [TestFixture()] + public class EditorCompareWidgetBaseTest + { + private delegate void ColorAssertion (Color color); + + [Test()] + public void TestRemovalLineColorIsRed () + { + CheckCombinationsAreColor (new Hunk (0, 0, 1, 0), AssertIsRed); + CheckCombinationsAreColor (new Hunk (0, 0, 2, 0), AssertIsRed); + } + + [Test()] + public void TestAdditionLineColorIsGreen () + { + CheckCombinationsAreColor (new Hunk (0, 0, 0, 1), AssertIsGreen); + CheckCombinationsAreColor (new Hunk (0, 0, 0, 2), AssertIsGreen); + } + + [Test()] + public void TestAdditionAndRemovalLineColorIsGreen () + { + CheckCombinationsAreColor (new Hunk (0, 0, 1, 1), AssertIsBlue); + CheckCombinationsAreColor (new Hunk (0, 0, 2, 2), AssertIsBlue); + CheckCombinationsAreColor (new Hunk (0, 0, 1, 2), AssertIsBlue); + CheckCombinationsAreColor (new Hunk (0, 0, 2, 1), AssertIsBlue); + } + + [Ignore("No dark border colors with new flat design, borders have the same color")] + [Test()] + public void TestDarkColorsAreDarker () + { + CheckDarkColoursAreDarker (new Hunk (0, 0, 1, 0)); + CheckDarkColoursAreDarker (new Hunk (0, 0, 0, 1)); + CheckDarkColoursAreDarker (new Hunk (0, 0, 1, 1)); + } + + private void CheckCombinationsAreColor (Hunk hunk, ColorAssertion assertion) + { + assertion (GetColor (hunk, true, true)); + assertion (GetColor (hunk, true, false)); + assertion (GetColor (hunk, false, true)); + assertion (GetColor (hunk, false, false)); + } + + private Color GetColor (Hunk hunk, bool removeSide, bool dark) + { + return EditorCompareWidgetBase.GetColor (hunk, removeSide, dark, 1.0); + } + + private void AssertIsRed (Color color) + { + Assert.Greater (color.R, color.G); + Assert.Greater (color.R, color.B); + } + + private void AssertIsGreen (Color color) + { + Assert.Greater (color.G, color.R); + Assert.Greater (color.G, color.B); + } + + private void AssertIsBlue (Color color) + { + Assert.Greater (color.B, color.G); + Assert.Greater (color.B, color.R); + } + + private void CheckDarkColoursAreDarker (Hunk hunk) + { + Color dark = GetColor (hunk, true, true); + Color light = GetColor (hunk, true, false); + Assert.Less (dark.R, light.R); + Assert.Less (dark.B, light.B); + Assert.Less (dark.G, light.G); + } + } +} + diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj index 9a7b3b42c0..c5ac435cdb 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj @@ -99,6 +99,9 @@ </PropertyGroup> <ItemGroup> <Reference Include="System" /> + <Reference Include="Mono.Cairo" /> + <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> @@ -108,6 +111,7 @@ <Compile Include="..\MonoDevelop.VersionControl\MonoDevelop.VersionControl\RevisionHelpers.cs"> <Link>RevisionHelpers.cs</Link> </Compile> + <Compile Include="EditorCompareWidgetBaseTest.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj"> @@ -133,6 +137,11 @@ <Project>{EE6ED99F-CB12-4683-B055-D28FC7357A34}</Project> <Name>LibGit2Sharp</Name> </ProjectReference> + <ProjectReference Include="..\..\MonoDevelop.SourceEditor2\MonoDevelop.SourceEditor.csproj"> + <Project>{F8F92AA4-A376-4679-A9D4-60E7B7FBF477}</Project> + <Name>MonoDevelop.SourceEditor</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <Choose> <When Condition=" '$(Configuration)' == 'DebugMac' OR '$(Configuration)' == 'ReleaseMac' "> |