Skip to content

Commit 7b52c5f

Browse files
authored
Merge pull request #1402 from TestCentric/issue-1396-2
Fix bug when loading tcproj files
2 parents bb3bca1 + 06ab667 commit 7b52c5f

File tree

1 file changed

+11
-32
lines changed

1 file changed

+11
-32
lines changed

src/GuiRunner/TestModel/TestCentricProject.cs

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,22 @@ public void Load(string path)
9898
{
9999
ProjectPath = path;
100100

101-
using (StreamReader reader = new StreamReader(ProjectPath))
101+
try
102102
{
103-
XmlSerializer serializer = new XmlSerializer(typeof(NUnit.Engine.TestPackage));
103+
string fileContent = File.ReadAllText(ProjectPath);
104+
TestPackage newPackage = PackageHelper.FromXml(fileContent);
104105

105-
try
106-
{
107-
var newPackage = (NUnit.Engine.TestPackage)serializer.Deserialize(reader);
108-
109-
foreach (var subPackage in newPackage.SubPackages)
110-
{
111-
AddSubPackage(subPackage.FullName);
112-
}
106+
foreach (var subPackage in newPackage.SubPackages)
107+
AddSubPackage(subPackage.FullName);
113108

114-
LoadTests();
115-
}
116-
catch (Exception ex)
117-
{
118-
throw new Exception("Unable to deserialize TestProject.", ex);
119-
}
109+
LoadTests();
110+
}
111+
catch (Exception ex)
112+
{
113+
throw new Exception($"Unable to load TestProject from {path}", ex);
120114
}
121115

116+
122117
IsDirty = false;
123118
}
124119

@@ -134,22 +129,6 @@ public void Save()
134129
writer.Write(this.ToXml());
135130
}
136131

137-
//public void Save(TextWriter writer)
138-
//{
139-
// XmlSerializer serializer = new XmlSerializer(typeof(NUnit.Engine.TestPackage));
140-
141-
// try
142-
// {
143-
// serializer.Serialize(writer, this);
144-
// }
145-
// catch (Exception ex)
146-
// {
147-
// throw new Exception("Unable to serialize TestProject.", ex);
148-
// }
149-
150-
// IsDirty = false;
151-
//}
152-
153132
public void LoadTests()
154133
{
155134
_model.LoadTests(TestFiles);

0 commit comments

Comments
 (0)