diff --git a/test/TwinGet.AutomationInterface.Test/TestUtils/TestTwincatProject.cs b/test/TwinGet.AutomationInterface.Test/TestUtils/TestTwincatProject.cs index 877d8fe..d9e3b8a 100644 --- a/test/TwinGet.AutomationInterface.Test/TestUtils/TestTwincatProject.cs +++ b/test/TwinGet.AutomationInterface.Test/TestUtils/TestTwincatProject.cs @@ -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 ?? []); } } }