NoiseEngine/CubicNoiseTests/NoiseBuilderTests.cs

103 lines
2.8 KiB
C#
Raw Normal View History

2020-01-11 18:00:46 +00:00
using System;
using System.Collections.Generic;
using System.Text;
using CubicNoise;
2020-01-11 18:32:40 +00:00
using CubicNoise.Contracts;
2020-01-11 18:00:46 +00:00
using CubicNoise.Noisers;
using NUnit.Framework;
namespace CubicNoiseTests
{
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-11 18:32:40 +00:00
var engine = NoiseEngine.Create(new EngineParameters
{
Seed = "test seed".GetHashCode(),
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()
{
var engine = NoiseEngine.Create(new EngineParameters());
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
{
var engine = NoiseEngine.Create(null);
Assert.Fail("Null instead of parameters should not work.");
}
catch
{
Assert.That(true);
}
}
[Test]
public void PartialParameters()
{
var engine = NoiseEngine.Create(new EngineParameters
{
Seed = "test seed".GetHashCode(),
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
}
}
}