52 lines
No EOL
2 KiB
C#
52 lines
No EOL
2 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using JD.Application.View.Tracks;
|
|
using JD.Application.Tests.Model;
|
|
using JD.Audio.Annotations;
|
|
using NUnit.Framework;
|
|
using Is = JD.Application.Tests.Model.Is;
|
|
|
|
namespace JD.Application.Tests.View.Tracks
|
|
{
|
|
[TestFixture]
|
|
public class GraphicalWaveCurveTests
|
|
{
|
|
[Test]
|
|
public void Test_curve_returns_the_minimum_in_reverse_order()
|
|
{
|
|
var curve = new GraphicalWaveCurve();
|
|
curve.AddPoint(0, 0, 1);
|
|
curve.AddPoint(1, .25f, .75f);
|
|
Assert.That(curve.BuildPoints(), Is.EqualTo(new PointF[] { new PointF(0, 1), new PointF(1, .75f), new PointF(1, .25f), new PointF(0, 0) }));
|
|
}
|
|
|
|
[Test]
|
|
public void Test_BuildPoints_returns_the_maximum_points_joined_with_minimum_and_forms_a_closed_curve()
|
|
{
|
|
var wave = TestExtensions.CreateWave(10, TimeSpan.FromSeconds(10));
|
|
wave.AddBeatsPerSecond(1);
|
|
|
|
var curve = new GraphicalWaveCurve();
|
|
const float pointsPerBeat = 2f;
|
|
curve.AddBeats(wave.Channels[0], wave.UnitConverter, new BeatUnit(1), new BeatUnit(3), pointsPerBeat);
|
|
|
|
var xaxis = curve.BuildPoints().Select(point => point.X);
|
|
Assert.That(xaxis, Is.EqualTo(new[] { 1f, 1.5f, 2f, 2.5f, 3f, 3f, 2.5f, 2f, 1.5f, 1f }));
|
|
}
|
|
|
|
[Test]
|
|
public void Test_BuildPoints_ignores_samples_outside_the_wave()
|
|
{
|
|
var wave = TestExtensions.CreateWave(10, TimeSpan.FromSeconds(10));
|
|
wave.AddBeatsPerSecond(1);
|
|
|
|
var curve = new GraphicalWaveCurve();
|
|
curve.AddBeats(wave.Channels[0], wave.UnitConverter, new BeatUnit(-10), new BeatUnit(-5), 10);
|
|
Assert.That(curve.BuildPoints().Length, Is.EqualTo(0));
|
|
|
|
curve.AddBeats(wave.Channels[0], wave.UnitConverter, new BeatUnit(30), new BeatUnit(35), 10);
|
|
Assert.That(curve.BuildPoints().Length, Is.EqualTo(0));
|
|
}
|
|
}
|
|
} |