function unit = vs_trih2nc_test
%vs_trih2nc_test  unit test for vs_trih2nc, incl dry point mask
%
% Checks conversion of primary variables from NEFIS to netCDF using 
% Delft3D input matrices. The test valyes are hard-coded to match 
% those in the mdf and associated files.
%
%See also: VS_TRIH2NC, NETCDF, NCWRITESCHEMA, DELFT3D, DELFT3D_GRID_IMAGE
%          nc_cf_bounds2cor, nc_cf_cor2bounds

% TO DO: test also for missing variables in trih file

rehash toolbox % update textpad vs_trih2nc

OPT = vs_trih2nc;

RUNIDs = {'2x3','2x3spherical','2x3z'};
epsg   = {28992,[],28992};
OK     = [];

for iRUNID=1:3
for trajectory=0:1

   RUNID = RUNIDs{iRUNID};
   
   clear D
   if trajectory
   ncfile =   [pwd,filesep,'delft3d_case',filesep,RUNID,'_his',num2str(trajectory),'.nc'];
   else
   ncfile =   [pwd,filesep,'delft3d_case',filesep,RUNID,'_his.nc'];
   end
   vs_trih2nc([pwd,filesep,'delft3d_case',filesep,'trih-',RUNID,'.dat'],ncfile,'epsg',epsg{iRUNID},'ind',[1 2],'trajectory',trajectory);
  %D = nc2struct([pwd,filesep,        RUNID,'_his.nc' ]);
   %structshow(D)
   
   fid = fopen(strrep(ncfile,'.nc','.cdl'),'w');
   nc_dump(    ncfile,fid);
   fclose(fid);
   
end
end

unit = all(OK);
   
