Skip to content

Commit

Permalink
test: Refactored PLC project initialization in TestTwincatProject
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuca committed Feb 17, 2024
1 parent cee99d6 commit de23c1a
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ public TestTwincatProject(string name, string absolutePath)

using (StringReader reader = new(xmlContent))
{
TcSmProjectData tcSmProject = serializer.Deserialize(reader) as TcSmProjectData ?? throw new InvalidProjectFileFormat("The format of TwinCAT project file is invalid.", absolutePath);

if (tcSmProject.Project.Plc?.Projects is not null)
{
_plcProjects.AddRange(from ProjectElement project in tcSmProject.Project.Plc.Projects
let plcProject = new TestPlcProject(Path.Join(rootDir, project.PrjFilePath))
where plcProject is not null
select plcProject);
}
TcSmProjectData tcSmProject = serializer.Deserialize(reader) as TcSmProjectData ?? throw new InvalidProjectFileFormat("The format of TwinCAT project file is invalid.", absolutePath);

var plcProjects = tcSmProject.Project.Plc?.Projects?
.Select(x => new TestPlcProject(Path.Join(rootDir, x.PrjFilePath)));

_plcProjects = new(plcProjects ?? []);
}
}
}
Expand Down

0 comments on commit de23c1a

Please sign in to comment.