forked from machine/machine.specifications
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Source/Machine.Specifications.ReSharperRunner.6.1/MSpecUnitTestElementSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Xml; | ||
|
||
using JetBrains.ProjectModel; | ||
using JetBrains.ReSharper.UnitTestFramework; | ||
|
||
using Machine.Specifications.ReSharperRunner.Presentation; | ||
|
||
namespace Machine.Specifications.ReSharperRunner | ||
{ | ||
[SolutionComponent] | ||
public class MSpecUnitTestElementSerializer : IUnitTestElementSerializer | ||
{ | ||
readonly MSpecUnitTestProvider _provider; | ||
|
||
public MSpecUnitTestElementSerializer(MSpecUnitTestProvider provider) | ||
{ | ||
_provider = provider; | ||
} | ||
|
||
public void SerializeElement(XmlElement parent, IUnitTestElement element) | ||
{ | ||
var e = element as ISerializableElement; | ||
if (e != null) | ||
{ | ||
e.WriteToXml(parent); | ||
parent.SetAttribute("elementType", e.GetType().Name); | ||
} | ||
} | ||
|
||
public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement) | ||
{ | ||
var typeName = parent.GetAttribute("elemenType"); | ||
|
||
if (Equals(typeName, "ContextElement")) | ||
return ContextElement.ReadFromXml(parent, parentElement, _provider); | ||
if (Equals(typeName, "BehaviorElement")) | ||
return BehaviorElement.ReadFromXml(parent, parentElement, _provider); | ||
if (Equals(typeName, "BehaviorSpecificationElement")) | ||
return BehaviorSpecificationElement.ReadFromXml(parent, parentElement, _provider); | ||
if (Equals(typeName, "ContextSpecificationElement")) | ||
return ContextSpecificationElement.ReadFromXml(parent, parentElement, _provider); | ||
|
||
return null; | ||
} | ||
|
||
public IUnitTestProvider Provider | ||
{ | ||
get { return _provider; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters