private void Randomize_Start(IEnumerable <TObject> actualObjects, IBounds bounds, IEnumerable <TimeBounds> expectedBounds, TempoMap tempoMap) { for (int i = 0; i < RepeatRandomizationCount; i++) { var clonedActualObjects = actualObjects.Select(o => o != null ? ObjectMethods.Clone(o) : default(TObject)).ToList(); Randomize(LengthedObjectTarget.Start, clonedActualObjects, bounds, expectedBounds, tempoMap); } }
private TObject CloneAndChangeTimeAndLength(TObject obj, long time, long length) { var result = ObjectMethods.Clone(obj); ObjectMethods.SetTime(result, time); ObjectMethods.SetLength(result, length); return(result); }
public void SplitAtDistance_FullLengthRatio(LengthedObjectTarget from) { var tempoMap = TempoMap.Default; var inputObjects = CreateInputObjects(1000); var ratio = 1.0; var expectedObjects = inputObjects.Select(o => ObjectMethods.Clone(o)); var actualObjects = Splitter.SplitAtDistance(inputObjects, ratio, TimeSpanType.Midi, from, tempoMap); ObjectMethods.AssertCollectionsAreEqual(expectedObjects, actualObjects); }
public void SplitAtDistance_BigDistance(LengthedObjectTarget from) { var tempoMap = TempoMap.Default; var inputObjects = CreateInputObjects(1000); var distance = (MidiTimeSpan)1000; var expectedObjects = inputObjects.Select(o => ObjectMethods.Clone(o)); var actualObjects = Splitter.SplitAtDistance(inputObjects, distance, from, tempoMap); ObjectMethods.AssertCollectionsAreEqual(expectedObjects, actualObjects); }
public void SplitByPartsNumber_OnePart() { var tempoMap = TempoMap.Default; var inputObjects = CreateInputObjects(100); var partsNumber = 1; var expectedObjects = inputObjects.Select(o => ObjectMethods.Clone(o)); var actualObjects = Splitter.SplitByPartsNumber(inputObjects, partsNumber, TimeSpanType.Midi, tempoMap); ObjectMethods.AssertCollectionsAreEqual(expectedObjects, actualObjects); }
public void SplitByStep_StepEqualObjectsLength() { var tempoMap = TempoMap.Default; var step = 1000L; var inputObjects = CreateInputObjects(step); var expectedObjects = inputObjects.Select(o => ObjectMethods.Clone(o)); var actualObjects = Splitter.SplitByStep(inputObjects, (MidiTimeSpan)step, tempoMap); ObjectMethods.AssertCollectionsAreEqual(expectedObjects, actualObjects); }
private IEnumerable <TObject> Split(TObject obj, IEnumerable <long> times) { var tail = ObjectMethods.Clone(obj); foreach (var time in times.OrderBy(t => t)) { var parts = SplitObject(tail, time); yield return(parts.LeftPart); tail = parts.RightPart; } yield return(tail); }
public void SplitAtDistance_FullLengthRatio(LengthedObjectTarget from) { var tempoMap = TempoMap.Default; var inputObjects = CreateInputObjects(1000); var ratio = 1.0; var expectedObjects = inputObjects.Select(o => ObjectMethods.Clone(o)); var actualObjects = Splitter.SplitAtDistance(inputObjects, ratio, TimeSpanType.Midi, from, tempoMap); MidiAsserts.AreEqual( expectedObjects.OfType <ITimedObject>(), actualObjects.OfType <ITimedObject>(), true, 0, "Objects are invalid."); }
public void SplitByPartsNumber_OnePart() { var tempoMap = TempoMap.Default; var inputObjects = CreateInputObjects(100); var partsNumber = 1; var expectedObjects = inputObjects.Select(o => ObjectMethods.Clone(o)); var actualObjects = Splitter.SplitByPartsNumber(inputObjects, partsNumber, TimeSpanType.Midi, tempoMap); MidiAsserts.AreEqual( expectedObjects.OfType <ITimedObject>(), actualObjects.OfType <ITimedObject>(), true, 0, "Objects are invalid."); }
public void SplitByStep_StepEqualObjectsLength() { var tempoMap = TempoMap.Default; var step = 1000L; var inputObjects = CreateInputObjects(step); var expectedObjects = inputObjects.Select(o => ObjectMethods.Clone(o)); var actualObjects = Splitter.SplitByStep(inputObjects, (MidiTimeSpan)step, tempoMap); MidiAsserts.AreEqual( expectedObjects.OfType <ITimedObject>(), actualObjects.OfType <ITimedObject>(), true, 0, "Objects are invalid."); }
private SplitData SplitByGrid_ClonesExpected(IEnumerable <TObject> inputObjects, ITimeSpan gridStart, IEnumerable <ITimeSpan> gridSteps, TempoMap tempoMap) { var expectedObjects = inputObjects.Select(o => o == null ? default(TObject) : ObjectMethods.Clone(o)).ToArray(); var actualObjects = Splitter.SplitByGrid(inputObjects, new SteppedGrid(gridStart, gridSteps), tempoMap).ToArray(); ObjectMethods.AssertCollectionsAreEqual(expectedObjects, actualObjects); return(new SplitData(inputObjects, expectedObjects, actualObjects)); }
public void SplitByPartsNumber_ZeroLength() { var tempoMap = TempoMap.Default; var inputObjects = CreateInputObjects(0); var partsNumber = 10; var expectedObjects = inputObjects.SelectMany(o => Enumerable.Range(0, partsNumber).Select(i => ObjectMethods.Clone(o))); var actualObjects = Splitter.SplitByPartsNumber(inputObjects, partsNumber, TimeSpanType.Midi, tempoMap).ToArray(); ObjectMethods.AssertCollectionsAreEqual(expectedObjects, actualObjects); }