1+ classdef AdmittanceScanHVDCUnitTest < matlab .unittest .TestCase
2+ % This MATLAB unit test is used to run all the codes used in the
3+ % Design and Analysis of Admittance Scan PRBS example.
4+ % Copyright 2024 The MathWorks, Inc.
5+ properties
6+ modelname = " HVDCScan" ;
7+ openfigureListBefore
8+ end
9+ methods (TestMethodSetup )
10+ function listOpenFigures(testCase )
11+ % List all open figures
12+ testCase.openfigureListBefore = findall(0 ,' Type' ,' Figure' );
13+ end
14+ end
15+ methods (TestMethodTeardown )
16+ function closeOpenedFigures(testCase )
17+ % Close all figure opened during test
18+ figureListAfter = findall(0 ,' Type' ,' Figure' );
19+ figuresOpenedByTest = setdiff(figureListAfter , testCase .openfigureListBefore );
20+ arrayfun(@close , figuresOpenedByTest );
21+ end
22+ end
23+ methods (Test )
24+ function AdmittanceScanHVDCSimulateModel(testCase )
25+ % Test for the Admittance HVDC example model
26+ % Load system and add teardown
27+ load_system(testCase .modelname )
28+ testCase .addTeardown(@()close_system(testCase .modelname , 0 ));
29+ % Set parameters
30+ set_param(testCase .modelname , StopTime = " 0.5" )
31+ % Simulate model
32+ sim(testCase .modelname );
33+ end
34+ function HVDCScanRunMLX(testCase )
35+ % Test runs the main |.mlx| for VSC HVDC Scan
36+ % Load system and add teardown
37+ load_system(testCase .modelname )
38+ testCase .addTeardown(@()close_system(testCase .modelname , 0 ));
39+
40+ % suppress warning
41+ warningID = ' Ident:estimation:tfestLowerOrder' ;
42+ warningState = warning(' query' , warningID );
43+ warning(' off' , warningID );
44+ testCase .addTeardown(@() warning(warningState .state ,warningID ));
45+
46+ % Set parameters
47+ set_param(testCase .modelname , StopTime = " 6" )
48+ % Run |.mlx| script
49+ HVDCParameters
50+ VSCHVDCScanandStabilityAnalysis
51+ end
52+ end % methods (Test)
53+ end % classdef
0 commit comments