-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RemoveDuplicatedNotes property to SanitizingSettings
- Loading branch information
1 parent
9fbf2dc
commit 598cb1e
Showing
3 changed files
with
163 additions
and
29 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.RemoveDuplicatedNotes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
using Melanchall.DryWetMidi.Common; | ||
using Melanchall.DryWetMidi.Core; | ||
using Melanchall.DryWetMidi.Tools; | ||
using NUnit.Framework; | ||
|
||
namespace Melanchall.DryWetMidi.Tests.Tools | ||
{ | ||
[TestFixture] | ||
public sealed partial class SanitizerTests | ||
{ | ||
#region Test methods | ||
|
||
[Test] | ||
public void Sanitize_RemoveDuplicatedNotes_EmptyFile() => Sanitize( | ||
midiFile: new MidiFile(), | ||
settings: null, | ||
expectedMidiFile: new MidiFile()); | ||
|
||
[Test] | ||
public void Sanitize_RemoveDuplicatedNotes_NoNotes_1() => Sanitize( | ||
midiFile: new MidiFile( | ||
new TrackChunk( | ||
new TextEvent("A"))), | ||
settings: null, | ||
expectedMidiFile: new MidiFile( | ||
new TrackChunk( | ||
new TextEvent("A")))); | ||
|
||
[Test] | ||
public void Sanitize_RemoveDuplicatedNotes_NoNotes_2() => Sanitize( | ||
midiFile: new MidiFile( | ||
new TrackChunk( | ||
new TextEvent("A") { DeltaTime = 10 }, | ||
new TextEvent("B") { DeltaTime = 15 })), | ||
settings: new SanitizingSettings | ||
{ | ||
Trim = false | ||
}, | ||
expectedMidiFile: new MidiFile( | ||
new TrackChunk( | ||
new TextEvent("A") { DeltaTime = 10 }, | ||
new TextEvent("B") { DeltaTime = 15 }))); | ||
|
||
[Test] | ||
public void Sanitize_RemoveDuplicatedNotes_SingleNote_1() => Sanitize( | ||
midiFile: new MidiFile( | ||
new TrackChunk( | ||
new TextEvent("A") { DeltaTime = 10 }, | ||
new NoteOnEvent(), | ||
new TextEvent("B") { DeltaTime = 15 }, | ||
new NoteOffEvent())), | ||
settings: new SanitizingSettings | ||
{ | ||
Trim = false | ||
}, | ||
expectedMidiFile: new MidiFile( | ||
new TrackChunk( | ||
new TextEvent("A") { DeltaTime = 10 }, | ||
new NoteOnEvent(), | ||
new TextEvent("B") { DeltaTime = 15 }, | ||
new NoteOffEvent()))); | ||
|
||
[Test] | ||
public void Sanitize_RemoveDuplicatedNotes_SingleNote_2() => Sanitize( | ||
midiFile: new MidiFile( | ||
new TrackChunk( | ||
new NoteOnEvent(), | ||
new NoteOffEvent())), | ||
settings: null, | ||
expectedMidiFile: new MidiFile( | ||
new TrackChunk( | ||
new NoteOnEvent(), | ||
new NoteOffEvent()))); | ||
|
||
[Test] | ||
public void Sanitize_RemoveDuplicatedNotes_1() => Sanitize( | ||
midiFile: new MidiFile( | ||
new TrackChunk( | ||
new NoteOnEvent(), | ||
new NoteOffEvent(), | ||
new NoteOnEvent(), | ||
new NoteOffEvent())), | ||
settings: null, | ||
expectedMidiFile: new MidiFile( | ||
new TrackChunk( | ||
new NoteOnEvent(), | ||
new NoteOffEvent()))); | ||
|
||
[Test] | ||
public void Sanitize_RemoveDuplicatedNotes_2() => Sanitize( | ||
midiFile: new MidiFile( | ||
new TrackChunk( | ||
new NoteOnEvent(), | ||
new NoteOnEvent(), | ||
new NoteOffEvent(), | ||
new NoteOffEvent())), | ||
settings: null, | ||
expectedMidiFile: new MidiFile( | ||
new TrackChunk( | ||
new NoteOnEvent(), | ||
new NoteOffEvent()))); | ||
|
||
[Test] | ||
public void Sanitize_RemoveDuplicatedNotes_3() => Sanitize( | ||
midiFile: new MidiFile( | ||
new TrackChunk( | ||
new NoteOnEvent(), | ||
new NoteOnEvent() { Channel = (FourBitNumber)5 }, | ||
new NoteOnEvent(), | ||
new NoteOnEvent() { Channel = (FourBitNumber)5 }, | ||
new TextEvent("A") { DeltaTime = 20 }, | ||
new NoteOffEvent() { Channel = (FourBitNumber)5 }, | ||
new NoteOffEvent(), | ||
new NoteOffEvent() { Channel = (FourBitNumber)5 }, | ||
new NoteOffEvent())), | ||
settings: null, | ||
expectedMidiFile: new MidiFile( | ||
new TrackChunk( | ||
new NoteOnEvent(), | ||
new NoteOnEvent() { Channel = (FourBitNumber)5 }, | ||
new TextEvent("A") { DeltaTime = 20 }, | ||
new NoteOffEvent() { Channel = (FourBitNumber)5 }, | ||
new NoteOffEvent()))); | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters