Browse Source

Verify ColorBuilder throws on null and empty

af/merge-core
Jason Nelson 8 years ago
parent
commit
6a3688d098
  1. 31
      tests/ImageSharp.Tests/PixelFormats/ColorBuilderTests.cs

31
tests/ImageSharp.Tests/PixelFormats/ColorBuilderTests.cs

@ -0,0 +1,31 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Colors
{
public class ColorBuilderTests
{
[Fact]
public void ParseHexLeadingPoundIsOptional()
{
Assert.Equal(new Rgb24(0, 128, 128), ColorBuilder<Rgb24>.FromHex("#008080"));
Assert.Equal(new Rgb24(0, 128, 128), ColorBuilder<Rgb24>.FromHex("008080"));
}
[Fact]
public void ParseHexThrowsOnEmpty()
{
Assert.Throws<ArgumentException>(() => ColorBuilder<Rgb24>.FromHex(""));
}
[Fact]
public void ParseHexThrowsOnNull()
{
Assert.Throws<ArgumentNullException>(() => ColorBuilder<Rgb24>.FromHex(null));
}
}
}
Loading…
Cancel
Save