MatrixBerryCore
AConfRepoMgrVersionedTC.m
Go to the documentation of this file.
1 classdef AConfRepoMgrVersionedTC < matlab.unittest.TestCase
2  properties (Access=protected)
3  cm
4  SDefaultEthalon=struct('firstProp','alpha','secondProp','beta');
5  factory
6  end
7  methods (Access=private)
8  function self=initData(self)
9  import mxberry.conf.test.*;
10 
11  self.cm=self.factory.getInstance();
12  self.cm.removeAll();
13  SConfA=struct('confName','testConfA','alpha',0,'beta',0);
14  SConfB=struct('confName','testConfB','alpha',11,'beta',11);
15  %
16  self.cm.putConf('testConfA',SConfA,0);
17  self.cm.putConf('testConfB',SConfB,0);
18  end
19  end
20  methods
21  function self = AConfRepoMgrVersionedTC(varargin)
22  self = self@matlab.unittest.TestCase(varargin{:});
23  end
24  end
25  properties (MethodSetupParameter, Abstract)
26  factoryParam
27  end
28  methods (TestMethodSetup)
29  function self = setUp(self,factoryParam)
30  self.factory=factoryParam;
31  self=self.initData();
32  end
33  end
34  methods
35  function aux_checkUpdate(self,cm)
36  [SConfB,confVersionB]=cm.getConf('testConfB');
37  [SConfA,confVersionA]=cm.getConf('testConfA');
38  self.verifyEqual(2,SConfA.beta);
39  self.verifyEqual(103,confVersionA);
40  self.verifyEqual('testConfA',SConfA.confName);
41  self.verifyEqual(11,SConfB.beta);
42  self.verifyEqual(0,confVersionB);
43  self.verifyEqual('testConfB',SConfB.confName);
44  end
45  function aux_checkUpdateAll(self,cm,isOkExp)
46  if nargin<3
47  isOkExp=true;
48  end
49  [SConfA,confVersionA]=cm.getConf('testConfA');
50  [SConfB,confVersionB]=cm.getConf('testConfB');
51  self.verifyEqual(isOkExp,isequal(2,SConfA.beta));
52  self.verifyEqual(isOkExp,isequal(103,confVersionA));
53  self.verifyEqual(true,...
54  isequal('testConfA',SConfA.confName));
55  self.verifyEqual(isOkExp,...
56  isequal(2,SConfB.beta));
57  self.verifyEqual(isOkExp,...
58  isequal(103,confVersionB));
59  self.verifyEqual(true,...
60  isequal('testConfB',SConfB.confName));
61  end
62  end
63  methods (Test)
64  function self=test_update(self)
65  self.cm.updateConf('testConfA');
66  self.aux_checkUpdate(self.cm);
67  end
68  function self=test_updateAll(self)
69  self.cm.updateAll();
70  self.aux_checkUpdateAll(self.cm);
71  end
72  end
73 end