NoiseEngine/NoiseEngineTests/NoiseBuilderTests.cs

103 lines
2.8 KiB
C#
Raw Permalink Normal View History

2020-01-11 18:00:46 +00:00
using System;
using System.Collections.Generic;
using System.Text;
2020-01-12 10:58:08 +00:00
using NoiseEngine;
using NoiseEngine.Contracts;
using NoiseEngine.Noisers;
2020-01-11 18:00:46 +00:00
using NUnit.Framework;
2020-01-12 10:58:08 +00:00
namespace NoiseEngineTests
2020-01-11 18:00:46 +00:00
{
public class NoiseBuilderTests
{
[Test]
2020-01-11 18:32:40 +00:00
public void StraightCreation()
2020-01-11 18:00:46 +00:00
{
2020-01-12 10:58:08 +00:00
var engine = NoiseProcessor.Create(new EngineParameters
2020-01-11 18:32:40 +00:00
{
2020-01-11 22:18:34 +00:00
Seed = "test seed".GetDeterministicHashCode(),
2020-01-11 18:32:40 +00:00
Type = NoiseTypes.CUBIC_NOISE,
IntParameters = new Dictionary<IParameterName, int>
{
{ CubicNoiseIntParameters.OCTAVE, 57 },
{ CubicNoiseIntParameters.PERIOD_X, 12 },
{ CubicNoiseIntParameters.PERIOD_Y, 16 },
},
});
Assert.That(engine, Is.Not.Null);
try
{
engine.Get(16f);
engine.Get(16f, 18f);
}
catch
{
Assert.Fail("Noise engine seems not to be implemented.");
}
}
[Test]
public void NoParameters()
{
2020-01-12 10:58:08 +00:00
var engine = NoiseProcessor.Create(new EngineParameters());
2020-01-11 18:32:40 +00:00
Assert.That(engine, Is.Not.Null);
try
{
engine.Get(16f);
engine.Get(16f, 18f);
Assert.That(true);
}
catch
{
Assert.Fail("Noise engine seems not to be implemented.");
}
}
[Test]
public void NullCheck()
{
try
{
2020-01-12 10:58:08 +00:00
var engine = NoiseProcessor.Create(null);
2020-01-11 18:32:40 +00:00
Assert.Fail("Null instead of parameters should not work.");
}
catch
{
Assert.That(true);
}
}
[Test]
public void PartialParameters()
{
2020-01-12 10:58:08 +00:00
var engine = NoiseProcessor.Create(new EngineParameters
2020-01-11 18:32:40 +00:00
{
2020-01-11 22:18:34 +00:00
Seed = "test seed".GetDeterministicHashCode(),
2020-01-11 18:32:40 +00:00
Type = NoiseTypes.CUBIC_NOISE,
IntParameters = new Dictionary<IParameterName, int>
{
{ CubicNoiseIntParameters.OCTAVE, 57 },
{ CubicNoiseIntParameters.PERIOD_X, 12 },
//{ CubicNoiseIntParameters.PERIOD_Y, 16 }, // is missing!
},
});
Assert.That(engine, Is.Not.Null);
try
{
engine.Get(16f);
engine.Get(16f, 18f);
}
catch
{
Assert.Fail("Noise engine seems not to be implemented.");
}
2020-01-11 18:00:46 +00:00
}
}
}