Files
tbd-station-14/Content.Tests/Client/ClickMapTest.cs
DrSmugleaf 5c0cf1b1a0 Use 'new' expression in places where the type is evident for content (#2590)
* Content.Client

* Content.Benchmarks

* Content.IntegrationTests

* Content.Server

* Content.Server.Database

* Content.Shared

* Content.Tests

* Merge fixes

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2020-11-27 21:00:49 +11:00

50 lines
1.5 KiB
C#

using Content.Client;
using NUnit.Framework;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
namespace Content.Tests.Client
{
[TestFixture]
public class ClickMapTest
{
[Test]
public void TestBasic()
{
var img = new Image<Rgba32>(2, 2)
{
[0, 0] = new(0, 0, 0, 0f),
[1, 0] = new(0, 0, 0, 1f),
[0, 1] = new(0, 0, 0, 1f),
[1, 1] = new(0, 0, 0, 0f)
};
var clickMap = ClickMapManager.ClickMap.FromImage(img, 0.5f);
Assert.That(clickMap.IsOccluded(0, 0), Is.False);
Assert.That(clickMap.IsOccluded(1, 0), Is.True);
Assert.That(clickMap.IsOccluded(0, 1), Is.True);
Assert.That(clickMap.IsOccluded(1, 1), Is.False);
}
[Test]
public void TestThreshold()
{
var img = new Image<Rgba32>(2, 2)
{
[0, 0] = new(0, 0, 0, 0f),
[1, 0] = new(0, 0, 0, 0.25f),
[0, 1] = new(0, 0, 0, 0.75f),
[1, 1] = new(0, 0, 0, 1f)
};
var clickMap = ClickMapManager.ClickMap.FromImage(img, 0.5f);
Assert.That(clickMap.IsOccluded(0, 0), Is.False);
Assert.That(clickMap.IsOccluded(1, 0), Is.False);
Assert.That(clickMap.IsOccluded(0, 1), Is.True);
Assert.That(clickMap.IsOccluded(1, 1), Is.True);
}
}
}