Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 308b1b8

Browse files
committed
First steps on tests refactoring
1 parent 2d5b44d commit 308b1b8

File tree

5 files changed

+71
-38
lines changed

5 files changed

+71
-38
lines changed

ColorSharpTests/ColorSharpTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<Compile Include="tests\LightSpectrums\RegularLightSpectrumTest.cs" />
4040
<Compile Include="tests\Illuminants\D65Test.cs" />
4141
<Compile Include="tests\Illuminants\ATest.cs" />
42+
<Compile Include="tests\ColorSpaces\AColorTest.cs" />
4243
</ItemGroup>
4344
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4445
<ItemGroup>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* The MIT License (MIT)
3+
* Copyright (c) 2014 Andrés Correa Casablanca
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
/**
25+
* Contributors:
26+
* - Andrés Correa Casablanca <castarco@gmail.com , castarco@litipk.com>
27+
*/
28+
29+
30+
using NUnit.Framework;
31+
using Litipk.ColorSharp.ColorSpaces;
32+
33+
namespace Litipk.ColorSharpTests
34+
{
35+
[TestFixture]
36+
public class AColorTest
37+
{
38+
[Test]
39+
public void TestConversionSimpleChains()
40+
{
41+
// From XYZ
42+
Assert.AreEqual (
43+
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIExyY> (),
44+
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<SRGB> ().ConvertTo<CIExyY> ()
45+
);
46+
47+
Assert.AreEqual (
48+
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<SRGB> (),
49+
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIExyY> ().ConvertTo<SRGB> ()
50+
);
51+
52+
Assert.AreEqual (
53+
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIEUCS> (),
54+
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIExyY> ().ConvertTo<CIEUCS> ()
55+
);
56+
57+
Assert.AreEqual (
58+
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIExyY> (),
59+
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIEUCS> ().ConvertTo<CIExyY> ()
60+
);
61+
62+
// From xyY
63+
Assert.AreEqual (
64+
new CIExyY (0.5, 0.5, 1.0).ConvertTo<SRGB>(),
65+
new CIExyY (0.5, 0.5, 1.0).ConvertTo<CIEXYZ>().ConvertTo<SRGB>()
66+
);
67+
}
68+
}
69+
}

ColorSharpTests/tests/ColorSpaces/CIEXYZTest.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,6 @@ namespace Litipk.ColorSharpTests
3636
[TestFixture]
3737
public class CIEXYZTest
3838
{
39-
[Test]
40-
public void TestConversionSimpleChains()
41-
{
42-
Assert.AreEqual (
43-
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIExyY> (),
44-
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<SRGB> ().ConvertTo<CIExyY> ()
45-
);
4639

47-
Assert.AreEqual (
48-
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<SRGB> (),
49-
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIExyY> ().ConvertTo<SRGB> ()
50-
);
51-
52-
Assert.AreEqual (
53-
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIEUCS> (),
54-
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIExyY> ().ConvertTo<CIEUCS> ()
55-
);
56-
57-
Assert.AreEqual (
58-
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIExyY> (),
59-
new CIEXYZ (50.0, 60.0, 30.0).ConvertTo<CIEUCS> ().ConvertTo<CIExyY> ()
60-
);
61-
}
6240
}
6341
}

ColorSharpTests/tests/ColorSpaces/CIExyYTest.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ namespace Litipk.ColorSharpTests
3535
[TestFixture]
3636
public class CIExyYTest
3737
{
38-
[Test]
39-
public void TestConversions()
40-
{
41-
Assert.AreEqual (
42-
new CIExyY (0.5, 0.5, 1.0).ConvertTo<SRGB>(),
43-
new CIExyY (0.5, 0.5, 1.0).ConvertTo<CIEXYZ>().ConvertTo<SRGB>()
44-
);
45-
}
46-
4738
[Test]
4839
public void TestIsInsideColorSpace()
4940
{

ColorSharpTests/tests/Illuminants/D65Test.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,11 @@ public void TestRGBValue ()
6060
[Test]
6161
public void TestCIExyYVaue ()
6262
{
63-
var pointA = CIE_D65.XYZ_Sample.ToCIExyY (ConversionStrategy.Default);
63+
var pointA = CIE_D65.XYZ_Sample.ToCIExyY ();
6464

6565
// Because there are a lot of transformations, we can't ensure a very little delta
6666
Assert.AreEqual (0.31271, pointA.x, 0.00002);
6767
Assert.AreEqual (0.32902, pointA.y, 0.00001);
68-
69-
var pointB = CIE_D65.XYZ_Sample.ToCIExyY (ConversionStrategy.WaveLength1NmStep);
70-
71-
// Because there are a lot of transformations, we can't ensure a very little delta
72-
Assert.AreEqual (0.31271, pointB.x, 0.00001);
73-
Assert.AreEqual (0.32902, pointB.y, 0.00001);
7468
}
7569
}
7670
}

0 commit comments

Comments
 (0)