Skip to content

Commit

Permalink
Merge pull request #123 from CoraleStudios/develop
Browse files Browse the repository at this point in the history
[RELEASE] v3.0
  • Loading branch information
brandonscott committed Nov 24, 2015
2 parents 3a76cc5 + 27b8c27 commit 73d58c1
Show file tree
Hide file tree
Showing 66 changed files with 1,584 additions and 1,588 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[*]
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{cs,ps1,xml}]
charset = utf-8

[*.sln]
indent_style = tab

[*.{csproj,yml,nuspec},packages.config]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions Corale.Colore.Tests/Corale.Colore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
Expand Down
214 changes: 176 additions & 38 deletions Corale.Colore.Tests/Core/ColorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,70 +34,111 @@ namespace Corale.Colore.Tests.Core

using NUnit.Framework;

using SystemColor = System.Drawing.Color;
using WpfColor = System.Windows.Media.Color;

[TestFixture]
public class ColorTests
{
[Test]
public void ShouldConstructCorrectly()
{
Assert.AreEqual(new Color(0x00123456).Value, 0x00123456);
Assert.AreEqual(new Color(0x78123456).Value, 0x78123456);
}

[Test]
public void ShouldConstructFromColor()
{
var c = new Color(0x00123456);
var c = new Color(0x78123456);
Assert.AreEqual(new Color(c), c);
}

[Test]
public void ShouldConvertRgbBytesCorrectly()
{
const uint V = 0x00FFFFFF;
const byte R = 255;
const byte G = 255;
const byte B = 255;
var c = new Color(R, G, B);
const uint V = 0x8056F5C8;
const byte R = 200;
const byte G = 245;
const byte B = 86;
const byte A = 128;
var c = new Color(R, G, B, A);
Assert.AreEqual(c.Value, V);
Assert.AreEqual(c.R, R);
Assert.AreEqual(c.G, G);
Assert.AreEqual(c.B, B);
Assert.AreEqual(c.A, A);
}

[Test]
public void ShouldConvertRgbDoublesCorrectly()
{
const uint V = 0x00FFFFFF;
const double R = 1.0;
const double G = 1.0;
const double B = 1.0;
const byte Expected = 255;
var c = new Color(R, G, B);
const uint V = 0x7F3D89CC;
const double R = 0.8;
const double G = 0.54;
const double B = 0.24;
const double A = 0.5;
const byte ExpectedR = (byte)(R * 255);
const byte ExpectedG = (byte)(G * 255);
const byte ExpectedB = (byte)(B * 255);
const byte ExpectedA = (byte)(A * 255);
var c = new Color(R, G, B, A);
Assert.AreEqual(c.Value, V);
Assert.AreEqual(c.R, Expected);
Assert.AreEqual(c.G, Expected);
Assert.AreEqual(c.B, Expected);
Assert.AreEqual(c.R, ExpectedR);
Assert.AreEqual(c.G, ExpectedG);
Assert.AreEqual(c.B, ExpectedB);
Assert.AreEqual(c.A, ExpectedA);
}

[Test]
public void ShouldConvertRgbFloatsCorrectly()
{
const uint V = 0x00FFFFFF;
const float R = 1.0f;
const float G = 1.0f;
const float B = 1.0f;
const byte Expected = 255;
var c = new Color(R, G, B);
const uint V = 0xD8E533CC;
const float R = 0.8f;
const float G = 0.2f;
const float B = 0.9f;
const float A = 0.85f;
const byte ExpectedR = (byte)(R * 255);
const byte ExpectedG = (byte)(G * 255);
const byte ExpectedB = (byte)(B * 255);
const byte ExpectedA = (byte)(A * 255);
var c = new Color(R, G, B, A);
Assert.AreEqual(c.Value, V);
Assert.AreEqual(c.R, Expected);
Assert.AreEqual(c.G, Expected);
Assert.AreEqual(c.B, Expected);
Assert.AreEqual(c.R, ExpectedR);
Assert.AreEqual(c.G, ExpectedG);
Assert.AreEqual(c.B, ExpectedB);
Assert.AreEqual(c.A, ExpectedA);
}

[Test]
public void ShouldConstructFromArgb()
{
var expected = new Color(0x12345678);
var actual = Color.FromArgb(0x12785634);

Assert.AreEqual(expected.Value, actual.Value);
Assert.AreEqual(expected.R, actual.R);
Assert.AreEqual(expected.G, actual.G);
Assert.AreEqual(expected.B, actual.B);
Assert.AreEqual(expected.A, actual.A);
}

[Test]
public void ShouldDefaultToBlackColor()
public void ShouldConstructFromRgb()
{
Assert.AreEqual(new Color(), Color.Black);
var expected = new Color(0xFF123456);
var actual = Color.FromRgb(0x563412);

Assert.AreEqual(expected.Value, actual.Value);
Assert.AreEqual(expected.R, actual.R);
Assert.AreEqual(expected.G, actual.G);
Assert.AreEqual(expected.B, actual.B);
Assert.AreEqual(expected.A, actual.A);
}

[Test]
public void ShouldDefaultToEmptyColor()
{
Assert.AreEqual(new Color().Value, 0);
}

[Test]
Expand All @@ -114,7 +155,7 @@ public void ShouldEqualIdenticalColor()
public void ShouldEqualIdenticalUint()
{
var a = new Color(255, 0, 255);
const uint B = 0x00FF00FF;
const uint B = 0xFFFF00FF;
Assert.AreEqual(a, B);
Assert.True(a == B);
Assert.False(a != B);
Expand Down Expand Up @@ -206,46 +247,143 @@ public void UintShouldNotEqualDifferentColor()
}

[Test]
public void ShouldConstructFromSystemColor()
public void ShouldConvertFromSystemColor()
{
var source = System.Drawing.Color.FromArgb(5, 10, 15);
var coloreColor = new Color(source);
var source = SystemColor.FromArgb(5, 10, 15, 20);
var coloreColor = Color.FromSystemColor(source);

Assert.AreEqual(source.R, coloreColor.R);
Assert.AreEqual(source.G, coloreColor.G);
Assert.AreEqual(source.B, coloreColor.B);
Assert.AreEqual(source.A, coloreColor.A);
}

[Test]
public void ShouldConvertToSystemColor()
public void ShouldExplicitCastToSystemColor()
{
var coloreColor = new Color(1, 2, 4);
var systemColor = (System.Drawing.Color)coloreColor;
var coloreColor = new Color(1, 2, 4, 8);
var systemColor = (SystemColor)coloreColor;

Assert.AreEqual(coloreColor.R, systemColor.R);
Assert.AreEqual(coloreColor.G, systemColor.G);
Assert.AreEqual(coloreColor.B, systemColor.B);
Assert.AreEqual(coloreColor.A, systemColor.A);
}

[Test]
public void ShouldConvertFromSystemColor()
public void ShouldExplicitCastFromSystemColor()
{
var systemColor = System.Drawing.Color.FromArgb(5, 10, 15);
var systemColor = SystemColor.FromArgb(5, 10, 15, 20);
var coloreColor = (Color)systemColor;

Assert.AreEqual(systemColor.R, coloreColor.R);
Assert.AreEqual(systemColor.G, coloreColor.G);
Assert.AreEqual(systemColor.B, coloreColor.B);
Assert.AreEqual(systemColor.A, coloreColor.A);
}

[Test]
public void ShouldImplicitCastToSystemColor()
{
var coloreColor = new Color(1, 2, 4, 8);
SystemColor systemColor = coloreColor;

Assert.AreEqual(coloreColor.R, systemColor.R);
Assert.AreEqual(coloreColor.G, systemColor.G);
Assert.AreEqual(coloreColor.B, systemColor.B);
Assert.AreEqual(coloreColor.A, systemColor.A);
}

[Test]
public void ShouldImplicitCastFromSystemColor()
{
var systemColor = SystemColor.FromArgb(5, 10, 15, 20);
Color coloreColor = systemColor;

Assert.AreEqual(systemColor.R, coloreColor.R);
Assert.AreEqual(systemColor.G, coloreColor.G);
Assert.AreEqual(systemColor.B, coloreColor.B);
Assert.AreEqual(systemColor.A, coloreColor.A);
}

[Test]
public void ShouldEqualSystemColorUsingOverload()
{
var coloreColor = new Color(1, 2, 3);
var systemColor = System.Drawing.Color.FromArgb(1, 2, 3);
var coloreColor = new Color(1, 2, 3, 8);
var systemColor = SystemColor.FromArgb(8, 1, 2, 3);

Assert.True(coloreColor.Equals(systemColor));
Assert.AreEqual(coloreColor, systemColor);
}

[Test]
public void ShouldConvertFromWpfColor()
{
var wpfColor = WpfColor.FromArgb(5, 10, 15, 20);
var coloreColor = Color.FromWpfColor(wpfColor);

Assert.AreEqual(wpfColor.R, coloreColor.R);
Assert.AreEqual(wpfColor.G, coloreColor.G);
Assert.AreEqual(wpfColor.B, coloreColor.B);
Assert.AreEqual(wpfColor.A, coloreColor.A);
}

[Test]
public void ShouldExplicitCastToWpfColor()
{
var coloreColor = new Color(1, 2, 4, 8);
var wpfColor = (WpfColor)coloreColor;

Assert.AreEqual(coloreColor.R, wpfColor.R);
Assert.AreEqual(coloreColor.G, wpfColor.G);
Assert.AreEqual(coloreColor.B, wpfColor.B);
Assert.AreEqual(coloreColor.A, wpfColor.A);
}

[Test]
public void ShouldExplicitCastFromWpfColor()
{
var wpfColor = WpfColor.FromArgb(5, 10, 15, 20);
var coloreColor = (Color)wpfColor;

Assert.AreEqual(wpfColor.R, coloreColor.R);
Assert.AreEqual(wpfColor.G, coloreColor.G);
Assert.AreEqual(wpfColor.B, coloreColor.B);
Assert.AreEqual(wpfColor.A, coloreColor.A);
}

[Test]
public void ShouldImplicitCastToWpfColor()
{
var coloreColor = new Color(1, 2, 4, 8);
WpfColor wpfColor = coloreColor;

Assert.AreEqual(coloreColor.R, wpfColor.R);
Assert.AreEqual(coloreColor.G, wpfColor.G);
Assert.AreEqual(coloreColor.B, wpfColor.B);
Assert.AreEqual(coloreColor.A, wpfColor.A);
}

[Test]
public void ShouldImplicitCastFromWpfColor()
{
var wpfColor = WpfColor.FromArgb(5, 10, 15, 20);
Color coloreColor = wpfColor;

Assert.AreEqual(wpfColor.R, coloreColor.R);
Assert.AreEqual(wpfColor.G, coloreColor.G);
Assert.AreEqual(wpfColor.B, coloreColor.B);
Assert.AreEqual(wpfColor.A, coloreColor.A);
}

[Test]
public void ShouldEqualWpfColorUsingOverload()
{
var coloreColor = new Color(1, 2, 3, 8);
var wpfColor = WpfColor.FromArgb(8, 1, 2, 3);

Assert.True(coloreColor.Equals(wpfColor));
Assert.AreEqual(coloreColor, wpfColor);
}
}
}
20 changes: 6 additions & 14 deletions Corale.Colore/Corale.Colore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
Expand All @@ -91,21 +92,8 @@
<Compile Include="ColoreException.cs" />
<Compile Include="Core\Chroma.cs" />
<Compile Include="Core\Color.cs" />
<Compile Include="Core\Color.Defines.cs" />
<Compile Include="Core\Device.cs" />
<Compile Include="Core\Device.Obsoletes.cs" />
<Compile Include="Core\GenericDevice.Obsoletes.cs" />
<Compile Include="Core\Headset.Obsoletes.cs" />
<Compile Include="Core\IDevice.Obsoletes.cs" />
<Compile Include="Core\IGenericDevice.Obsoletes.cs" />
<Compile Include="Core\IHeadset.Obsoletes.cs" />
<Compile Include="Core\IKeyboard.Obsoletes.cs" />
<Compile Include="Core\IKeypad.Obsoletes.cs" />
<Compile Include="Core\IMouse.Obsoletes.cs" />
<Compile Include="Core\IMousepad.Obsoletes.cs" />
<Compile Include="Core\Keyboard.Obsoletes.cs" />
<Compile Include="Core\Keypad.Obsoletes.cs" />
<Compile Include="Core\Mouse.Obsoletes.cs" />
<Compile Include="Core\Mousepad.Obsoletes.cs" />
<Compile Include="EnvironmentHelper.cs" />
<Compile Include="Core\GenericDevice.cs" />
<Compile Include="Core\Headset.cs" />
Expand Down Expand Up @@ -146,6 +134,8 @@
<Compile Include="Razer\Keyboard\Effects\Static.cs" />
<Compile Include="Razer\Keyboard\Effects\Wave.cs" />
<Compile Include="Razer\Keyboard\Key.cs" />
<Compile Include="Razer\Keyboard\UnsafeKeyAttribute.cs" />
<Compile Include="Razer\Keyboard\PositionData.cs" />
<Compile Include="Razer\Keypad\Constants.cs" />
<Compile Include="Razer\Keypad\Effects\Breathing.cs" />
<Compile Include="Razer\Keypad\Effects\BreathingType.cs" />
Expand All @@ -169,13 +159,15 @@
<Compile Include="Razer\Mouse\Effects\Breathing.cs" />
<Compile Include="Razer\Mouse\Effects\BreathingType.cs" />
<Compile Include="Razer\Mouse\Effects\Custom.cs" />
<Compile Include="Razer\Mouse\Effects\CustomGrid.cs" />
<Compile Include="Razer\Mouse\Effects\Direction.cs" />
<Compile Include="Razer\Mouse\Effects\Duration.cs" />
<Compile Include="Razer\Mouse\Effects\Effect.cs" />
<Compile Include="Razer\Mouse\Effects\None.cs" />
<Compile Include="Razer\Mouse\Effects\Reactive.cs" />
<Compile Include="Razer\Mouse\Effects\SpectrumCycling.cs" />
<Compile Include="Razer\Mouse\Effects\Wave.cs" />
<Compile Include="Razer\Mouse\GridLed.cs" />
<Compile Include="Razer\Mouse\Led.cs" />
<Compile Include="Razer\Mouse\Effects\Static.cs" />
<Compile Include="Razer\NativeCallException.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Corale.Colore/Corale.Colore.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<authors>$author$</authors>
<owners>Adam Hellberg, Brandon Scott</owners>
<licenseUrl>https://github.com/CoraleStudios/Colore/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/Corale/Colore</projectUrl>
<projectUrl>https://github.com/CoraleStudios/Colore</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<copyright>Copyright (c) 2015 by Adam Hellberg and Brandon Scott.</copyright>
Expand Down
Loading

0 comments on commit 73d58c1

Please sign in to comment.