1 classdef AConfRepoMgrTC < matlab.unittest.TestCase
2 properties (Access=
protected)
4 SDefaultEthalon=struct('firstProp','alpha','secondProp','beta');
7 methods (Access=protected)
8 function self=initData(self)
10 self.cm=self.factory.getInstance();
14 metaA=struct('a','1','b','2');
15 metaB=struct('a','11','b','22');
17 self.cm.putConf('testConfA',SConfA,100,metaA);
18 self.cm.putConf('testConfB',SConfB,200,metaB);
23 self = self@matlab.unittest.TestCase(varargin{:});
26 properties (MethodSetupParameter, Abstract)
29 methods (TestMethodSetup)
30 function self = setUp(
self,factoryParam)
36 function self = test_setGetConf(
self)
39 metaData=struct('a','111','b','222');
40 self.cm.putConf('testConfA',SConf,3,metaData);
41 [SRes,confVersion,metaDataRes]=self.cm.getConf('testConfA');
42 self.verifyEqual(isequaln(SConf,SRes),true);
44 self.verifyEqual(isequaln(metaData,metaDataRes),true);
45 self.verifyEqual(isequaln(3,confVersion),true);
47 function self = test_copyConfAndgetConfList(self)
50 self.cm.putConf('testConfA',SConf);
51 self.cm.copyConf('testConfA','testConfAA');
52 SRes=self.cm.getConf('testConfAA');
53 self.verifyEqual(isequaln(SConf,SRes),true);
54 self.cm.removeConf('testConfB');
55 confNameList=self.cm.getConfNameList();
56 isEqual=isequal(sort({
'testConfA',
'testConfAA'}),...
58 self.verifyEqual(isEqual,
true);
60 function self = test_isParam(
self)
63 self.cm.putConf('testConfA',SConf);
64 self.cm.selectConf('testConfA');
65 isPos=self.cm.isParam('dConf.gen.cdefs.gen.instTypeCode');
66 self.verifyEqual(isPos,true);
67 isPos=self.cm.isParam('dConf.gen.cdefs.gen.instTypeCode__');
68 self.verifyEqual(isPos,false);
69 isPos=self.cm.isParam('.dConf.gen.cdefs.gen.instTypeCode');
70 self.verifyEqual(isPos,true);
73 function self = test_setGetParamWithDot(self)
76 paramNameList={
'.dConf.backtest.calc.pairForecast.meanDec.nLags',...
77 'dConf.backtest.calc.pairForecast.meanDec.nLags'};
78 for iParam=1:length(paramNameList)
80 paramName=paramNameList{iParam};
81 self.cm.selectConf(
'testConfA');
82 paramVal=
self.cm.getParam(paramName);
84 self.cm.setParam(paramName,paramVal);
85 paramVal2=
self.cm.getParam(paramName);
86 self.verifyEqual(isequaln(paramVal,paramVal2),
true);
87 self.cm.selectConf(
'testConfB');
88 self.cm.setParam(paramName,Inf);
89 paramVal3=
self.cm.getParam(paramName);
90 self.verifyEqual(isequaln(Inf,paramVal3),
true);
91 self.cm.selectConf(
'testConfA');
92 paramVal5=
self.cm.getParam(paramName);
93 self.verifyEqual(isequaln(paramVal,paramVal5),
true);
96 function self = test_setGetParamNegative(
self) import
mxberry.conf.test.*;
99 paramName='.dConf.backtest.calc.pairForecast.meanDec.nLags123';
100 self.cm.selectConf('testConfA');
102 self.cm.getParam(paramName);
103 self.verifyEqual(true,false);
105 isOk=~isempty(strfind(meObj.identifier,...
106 'CONFREPOMANAGERANYSTORAGE:GETPARAM:invalidParam'));
107 self.verifyEqual(isOk,true);
110 function self = test_setParamInCache(self)
113 paramNameList={
'.dConf.backtest.calc.pairForecast.meanDec.nLags',...
114 'dConf.backtest.calc.pairForecast.meanDec.nLags'};
115 for iParam=1:length(paramNameList)
116 self=
self.initData();
117 paramName=paramNameList{iParam};
118 self.cm.selectConf(
'testConfA');
119 origParamValue=
self.cm.getParam(paramName);
121 self.cm.setParam(paramName,paramValue,
'writeDepth',
'cache');
122 self.verifyEqual(
true,
self.cm.isParam(paramName));
123 self.verifyEqual(paramValue,
self.cm.getParam(paramName));
124 self.cm.flushCache();
125 self.cm.selectConf(
'testConfA');
126 self.verifyEqual(
true,
self.cm.isParam(paramName));
127 self.verifyEqual(origParamValue,
self.cm.getParam(paramName));
128 paramName=[paramName,
'_2']; %#ok<AGROW>
130 self.cm.setParam(paramName,paramValue,
'writeDepth',
'cache');
131 self.verifyEqual(
true,
self.cm.isParam(paramName));
132 self.verifyEqual(paramValue,
self.cm.getParam(paramName));
133 self.cm.flushCache();
134 self.cm.selectConf(
'testConfA');
135 self.verifyEqual(
false,
self.cm.isParam(paramName));
function genteststruct(in inpNum)