diff --git a/+tests/+unit/InstallExtensionTest.m b/+tests/+unit/InstallExtensionTest.m new file mode 100644 index 00000000..afce4c56 --- /dev/null +++ b/+tests/+unit/InstallExtensionTest.m @@ -0,0 +1,49 @@ +classdef InstallExtensionTest < matlab.unittest.TestCase + + methods (TestClassSetup) + function setupClass(testCase) + % Get the root path of the matnwb repository + rootPath = misc.getMatnwbDir(); + + % Use a fixture to add the folder to the search path + testCase.applyFixture(matlab.unittest.fixtures.PathFixture(rootPath)); + + % Use a fixture to create a temporary working directory + testCase.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture); + generateCore('savedir', '.'); + end + end + + methods (Test) + function testInstallExtension(testCase) + nwbInstallExtension("ndx-miniscope", 'savedir', '.') + + testCase.verifyTrue(isfolder('./+types/+ndx_miniscope'), ... + 'Folder with extension types does not exist') + end + + function testUseInstalledExtension(testCase) + nwbObject = testCase.initNwbFile(); + + miniscopeDevice = types.ndx_miniscope.Miniscope(... + 'deviceType', 'test_device', ... + 'compression', 'GREY', ... + 'frameRate', '30fps', ... + 'framesPerFile', int8(100) ); + + nwbObject.general_devices.set('TestMiniscope', miniscopeDevice); + + testCase.verifyClass(nwbObject.general_devices.get('TestMiniscope'), ... + 'types.ndx_miniscope.Miniscope') + end + end + + methods (Static) + function nwb = initNwbFile() + nwb = NwbFile( ... + 'session_description', 'test file for nwb extension', ... + 'identifier', 'export_test', ... + 'session_start_time', datetime("now", 'TimeZone', 'local') ); + end + end +end