Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into implementation-root…
Browse files Browse the repository at this point in the history
…-dictionary
  • Loading branch information
DomCR committed Oct 30, 2023
2 parents 3e87327 + cfa7583 commit 4dc0e8e
Show file tree
Hide file tree
Showing 75 changed files with 14,592 additions and 1,897 deletions.
66 changes: 60 additions & 6 deletions ACadSharp.Tests/ColorTests.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
using System;
using ACadSharp.Tests.Common;
using System;
using System.Drawing;
using Xunit;
using Xunit.Abstractions;

namespace ACadSharp.Tests
{
public class ColorTests
{
private ITestOutputHelper _output;

public ColorTests(ITestOutputHelper output)
{
_output = output;
}

[Fact]
public void IndexedColorProperties()
{
Assert.True(new Color(0).IsByBlock);
Assert.True(new Color(256).IsByLayer);
Assert.True(new Color(2705).IsTrueColor);
Assert.True(new Color(2706).IsTrueColor);
Assert.True(new Color(2707).IsTrueColor);
Assert.True(new Color(2708).IsTrueColor);

Assert.True(Color.FromTrueColor(2705).IsTrueColor);
Assert.True(Color.FromTrueColor(2706).IsTrueColor);
Assert.True(Color.FromTrueColor(2707).IsTrueColor);
Assert.True(Color.FromTrueColor(2708).IsTrueColor);
}

[Fact]
Expand Down Expand Up @@ -61,6 +71,50 @@ public void HandlesIndexedColors()
}
}

[Fact]
public void GetRgbTest()
{
CSMathRandom random = new CSMathRandom();

byte r = random.Next<byte>();
byte g = random.Next<byte>();
byte b = random.Next<byte>();

Color color = new Color(r, g, b);

this._output.WriteLine($"Color value: {color}");

var rgb = color.GetRgb();

Assert.Equal(r, rgb[0]);
Assert.Equal(g, rgb[1]);
Assert.Equal(b, rgb[2]);
}

[Fact]
public void ByLayerTest()
{
Color byLayer = Color.ByLayer;

this._output.WriteLine($"Color value: {byLayer}");

Assert.True(byLayer.IsByLayer);
Assert.False(byLayer.IsByBlock);
Assert.Equal(256, byLayer.Index);
}

[Fact]
public void ByBlockTest()
{
Color byBlock = Color.ByBlock;

this._output.WriteLine($"Color value: {byBlock}");

Assert.True(byBlock.IsByBlock);
Assert.False(byBlock.IsByLayer);
Assert.Equal(0, byBlock.Index);
}

private int int32FromInt24(byte[] array)
{
if (BitConverter.IsLittleEndian)
Expand Down
2 changes: 1 addition & 1 deletion ACadSharp.Tests/Common/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static CadObject createObject(Type type, Type original, bool randomize)
return null;
}

if (type == typeof(XRecrod)
if (type == typeof(XRecord)
|| type == typeof(PlotSettings)
|| type == typeof(Material)
|| type == typeof(MLStyle)
Expand Down
Loading

0 comments on commit 4dc0e8e

Please sign in to comment.