function OK = inivalue_test
%inivalue_test test for inivalue
%
%See also: inivalue

MTestCategory.DataAccess;
if TeamCity.running
    OK = true;
    TeamCity.ignore('Only matlab folder is checked out at the build agent. Therefore searching for OET R.url will not work.');
    return;
end

% a url file is has *.ini format
url = 'http://www.openearth.eu/';

iniFile = [fileparts(mfilename('fullpath')) filesep 'inivalue.ini'];
fid = fopen(iniFile,'w');
fprintf(fid,'%s\n','[InternetShortcut]');
fprintf(fid,'%s\n',['URL=',url]);
fclose(fid);

% test reading one keyName
S         = inivalue(iniFile,'InternetShortcut','URL');
OK        = strcmp(S,url);

% test reading one sectionName
S         = inivalue(iniFile,'InternetShortcut');
OK(end+1) = strcmp(S.URL,url);

% test reading one fileName
S        = inivalue(iniFile);
OK(end+1) = strcmp(S.InternetShortcut.URL,url);

% test reading file without sectionNames

iniFile = [fileparts(mfilename('fullpath')) filesep 'inivalue2.ini'];
fid = fopen(iniFile,'w');
fprintf(fid,'%s\n','a=3');
fclose(fid);

S = inivalue(iniFile,nan);

OK(end+1) = strcmp(S.a,'3');

% wrap up

OK = all(OK);
