Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified code/TMDD.sbproj
Binary file not shown.
Binary file modified code/TMDDApp.mlapp
Binary file not shown.
7 changes: 7 additions & 0 deletions resources/project/Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@
</Category>
</Info>
</File>
<File Location="tLampView.m">
<Info>
<Category UUID="FileClassCategory">
<Label UUID="test"/>
</Category>
</Info>
</File>
</File>
<File Location=".gitattributes">
<Info/>
Expand Down
72 changes: 72 additions & 0 deletions tests/tLampView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
% This test file was generated by Copilot. Validate generated output before use.
classdef tLampView < matlab.unittest.TestCase
properties
Model
LampViewObj
Parent
end

methods(TestMethodSetup)
function createLampView(testCase)
testCase.Parent = figure('Visible', 'off'); % Create a hidden figure for the lamp
testCase.Model = SimulationModel(); % Assuming SimulationModel is defined elsewhere
testCase.LampViewObj = LampView(testCase.Parent, testCase.Model);
end
end

methods(Test)
function testIsOnTrue(testCase)
simulate(testCase.Model, [0.5234,0.0485,0.0934,119,150,24]);

testCase.verifyTrue(testCase.LampViewObj.IsOn);
end

function testIsOnFalse(testCase)
simulate(testCase.Model, [0.5234,0.0485,0.0934,119,200,24]);

testCase.verifyFalse(testCase.LampViewObj.IsOn);
end

function testLampColorSuccess(testCase)
testCase.LampViewObj.IsOn = true;
expectedColor = testCase.LampViewObj.LampColorSucess;

actualColor = testCase.LampViewObj.LampObj.Color;

testCase.verifyEqual(actualColor, expectedColor, 'Lamp color should be success color when IsOn is true.');
end

function testLampColorFailure(testCase)
testCase.LampViewObj.IsOn = false;
expectedColor = testCase.LampViewObj.LampColorFailure;

actualColor = testCase.LampViewObj.LampObj.Color;

testCase.verifyEqual(actualColor, expectedColor, 'Lamp color should be failure color when IsOn is false.');
end

function testTooltipSuccess(testCase)
testCase.LampViewObj.IsOn = true;
expectedTooltip = char(compose("Target occupancy remains\n between thresholds"));

actualTooltip = testCase.LampViewObj.LampObj.Tooltip;

testCase.verifyEqual(actualTooltip, expectedTooltip, 'Tooltip should indicate success when IsOn is true.');
end

function testTooltipFailure(testCase)
testCase.LampViewObj.IsOn = false;
expectedTooltip = char(compose("Target occupancy does not remain\n between thresholds"));

actualTooltip = testCase.LampViewObj.LampObj.Tooltip;

testCase.verifyEqual(actualTooltip, expectedTooltip, 'Tooltip should indicate failure when IsOn is false.');
end
end

methods(TestMethodTeardown)
function closeFigure(testCase)
close(testCase.Parent);
end
end
end
Loading