Skip to content

Commit

Permalink
Create InstallExtensionTest.m
Browse files Browse the repository at this point in the history
  • Loading branch information
ehennestad committed Nov 28, 2024
1 parent bb3514b commit 184fa81
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions +tests/+unit/InstallExtensionTest.m
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 184fa81

Please sign in to comment.