diff --git a/Framework/MIKMIDI Tests/MIKMIDIChannelEventTests.m b/Framework/MIKMIDI Tests/MIKMIDIChannelEventTests.m new file mode 100644 index 00000000..11348699 --- /dev/null +++ b/Framework/MIKMIDI Tests/MIKMIDIChannelEventTests.m @@ -0,0 +1,55 @@ +// +// MIKMIDIChannelEventTests.m +// MIKMIDI Tests +// +// Created by Andrew R Madsen on 4/8/18. +// Copyright © 2018 Mixed In Key. All rights reserved. +// + +#import +#import + +@interface MIKMIDIChannelEventTests : XCTestCase + +@end + +@implementation MIKMIDIChannelEventTests + +- (void)testConvertingPolyphonicKeyPressureEventToCommand +{ + MIKMutableMIDIPolyphonicKeyPressureEvent *event = [[MIKMutableMIDIPolyphonicKeyPressureEvent alloc] init]; + event.channel = 3; + event.pressure = 42; + + XCTAssertEqual(event.channel, 3); + XCTAssertEqual(event.pressure, 42); + + MIKMIDIClock *clock = [MIKMIDIClock clock]; + + MIKMIDIPolyphonicKeyPressureCommand *command = nil; + XCTAssertNoThrow(command = (id)[MIKMIDICommand commandFromChannelEvent:event clock:clock]); + XCTAssertTrue([command isKindOfClass:[MIKMIDIPolyphonicKeyPressureCommand class]]); + XCTAssertNotNil(command); + XCTAssertEqual(command.channel, event.channel); + XCTAssertEqual(command.pressure, event.pressure); +} + +- (void)testConvertingChannelPressureEventToCommand +{ + MIKMutableMIDIChannelPressureEvent *event = [[MIKMutableMIDIChannelPressureEvent alloc] init]; + event.channel = 2; + event.pressure = 27; + XCTAssertEqual(event.channel, 2); + XCTAssertEqual(event.pressure, 27); + + MIKMIDIClock *clock = [MIKMIDIClock clock]; + + MIKMIDIChannelPressureCommand *command = nil; + XCTAssertNoThrow(command = (id)[MIKMIDICommand commandFromChannelEvent:event clock:clock]); + XCTAssertTrue([command isKindOfClass:[MIKMIDIChannelPressureCommand class]]); + XCTAssertNotNil(command); + XCTAssertEqual(command.channel, event.channel); + XCTAssertEqual(command.pressure, event.pressure); +} + +@end diff --git a/Framework/MIKMIDI.xcodeproj/project.pbxproj b/Framework/MIKMIDI.xcodeproj/project.pbxproj index 97911a84..ce0857da 100644 --- a/Framework/MIKMIDI.xcodeproj/project.pbxproj +++ b/Framework/MIKMIDI.xcodeproj/project.pbxproj @@ -290,6 +290,7 @@ 9DE259E519A7B4F800DA93E9 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DE259E419A7B4F800DA93E9 /* AudioUnit.framework */; }; 9DE259E619A7B50100DA93E9 /* CoreMIDI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D74EF2D17A7133900BEE89F /* CoreMIDI.framework */; }; 9DE259E819A7B50600DA93E9 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DE259E719A7B50600DA93E9 /* AudioToolbox.framework */; }; + 9DE824A6207AD02000761A07 /* MIKMIDIChannelEventTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DE824A5207AD02000761A07 /* MIKMIDIChannelEventTests.m */; }; 9DEBD03B1F7085DB00676C42 /* MIKMIDINoteCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DEBD0391F7085DB00676C42 /* MIKMIDINoteCommand.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9DEBD03C1F7085DB00676C42 /* MIKMIDINoteCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DEBD0391F7085DB00676C42 /* MIKMIDINoteCommand.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9DEBD03D1F7085DB00676C42 /* MIKMIDINoteCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DEBD03A1F7085DB00676C42 /* MIKMIDINoteCommand.m */; }; @@ -493,6 +494,7 @@ 9DCDDB591AB3514100F8347E /* MIKMIDISequencerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIKMIDISequencerTests.m; sourceTree = ""; }; 9DE259E419A7B4F800DA93E9 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; }; 9DE259E719A7B50600DA93E9 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + 9DE824A5207AD02000761A07 /* MIKMIDIChannelEventTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MIKMIDIChannelEventTests.m; sourceTree = ""; }; 9DEBD0391F7085DB00676C42 /* MIKMIDINoteCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDINoteCommand.h; sourceTree = ""; }; 9DEBD03A1F7085DB00676C42 /* MIKMIDINoteCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIKMIDINoteCommand.m; sourceTree = ""; }; 9DEBD0401F708B0E00676C42 /* MIKMIDINoteCommand_SubclassMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDINoteCommand_SubclassMethods.h; sourceTree = ""; }; @@ -572,6 +574,7 @@ 9D0225301CC92ECF0090EAB4 /* MIKMIDIMetaEventTests.m */, 9DCDDB591AB3514100F8347E /* MIKMIDISequencerTests.m */, 9D2ED25E1AFBD062000325CC /* MIKMIDIResponderChainTests.m */, + 9DE824A5207AD02000761A07 /* MIKMIDIChannelEventTests.m */, 9D4DF13C1AAB57430065F004 /* Supporting Files */, 9D4DF1501AAB57CD0065F004 /* Resources */, ); @@ -1209,6 +1212,7 @@ 9D2ED25F1AFBD062000325CC /* MIKMIDIResponderChainTests.m in Sources */, 9D4DF14D1AAB57800065F004 /* MIKMIDISequenceTests.m in Sources */, 9D4DF1541AAB60490065F004 /* MIKMIDITrackTests.m in Sources */, + 9DE824A6207AD02000761A07 /* MIKMIDIChannelEventTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };