-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#373 - Added unit test for variable output
- Loading branch information
1 parent
f7e5a41
commit 19d6f98
Showing
5 changed files
with
102 additions
and
3 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
85 changes: 85 additions & 0 deletions
85
MobiFlightUnitTests/MobiFlight/OutputConfig/VariableOutputTests.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,85 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MobiFlight.OutputConfig; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
|
||
namespace MobiFlight.OutputConfig.Tests | ||
{ | ||
[TestClass()] | ||
public class VariableOutputTests | ||
{ | ||
[TestMethod()] | ||
public void VariableOutputTest() | ||
{ | ||
VariableOutput o = new VariableOutput(); | ||
Assert.IsNotNull(o, "Object is null"); | ||
|
||
Assert.IsNotNull(o.Variable, "Variable is not null"); | ||
Assert.IsNotNull(o.Variable.Name, "Variable.Name is null"); | ||
} | ||
|
||
[TestMethod()] | ||
public void CloneTest() | ||
{ | ||
VariableOutput o = new VariableOutput(); | ||
o.Variable.Name = "Test"; | ||
VariableOutput c = o.Clone() as VariableOutput; | ||
Assert.IsNotNull(c, "Clone is null"); | ||
Assert.AreEqual(o.Variable.Name, c.Variable.Name, "Address are not the same"); | ||
} | ||
|
||
[TestMethod()] | ||
public void GetSchemaTest() | ||
{ | ||
LcdDisplay o = new LcdDisplay(); | ||
|
||
Assert.IsNull(o.GetSchema(), "Schema not null"); | ||
} | ||
|
||
[TestMethod()] | ||
public void ReadXmlTest() | ||
{ | ||
VariableOutput o = new VariableOutput(); | ||
|
||
String s = System.IO.File.ReadAllText(@"assets\MobiFlight\OutputConfig\VariableOutput\ReadXmlTest.1.xml"); | ||
StringReader sr = new StringReader(s); | ||
XmlReaderSettings settings = new XmlReaderSettings(); | ||
settings.IgnoreWhitespace = true; | ||
|
||
System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(sr, settings); | ||
xmlReader.ReadToDescendant("display"); | ||
o.ReadXml(xmlReader); | ||
|
||
Assert.AreEqual("ReadXMLTest", o.Variable.Name, "Variable.Name does not match."); | ||
} | ||
|
||
[TestMethod()] | ||
public void WriteXmlTest() | ||
{ | ||
StringWriter sw = new StringWriter(); | ||
XmlWriterSettings settings = new XmlWriterSettings(); | ||
settings.Encoding = System.Text.Encoding.UTF8; | ||
settings.Indent = true; | ||
//settings.NewLineHandling = NewLineHandling.Entitize; | ||
System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create(sw, settings); | ||
|
||
VariableOutput o = new VariableOutput(); | ||
o.Variable.Name = "WriteXMLTest"; | ||
|
||
xmlWriter.WriteStartElement("display"); | ||
o.WriteXml(xmlWriter); | ||
xmlWriter.WriteEndElement(); | ||
xmlWriter.Flush(); | ||
string s = sw.ToString(); | ||
|
||
String result = System.IO.File.ReadAllText(@"assets\MobiFlight\OutputConfig\VariableOutput\WriteXmlTest.1.xml"); | ||
|
||
Assert.AreEqual(s, result, "The both strings are not equal"); | ||
} | ||
} | ||
} |
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
Binary file added
BIN
+228 Bytes
MobiFlightUnitTests/assets/MobiFlight/OutputConfig/VariableOutput/ReadXmlTest.1.xml
Binary file not shown.
Binary file added
BIN
+230 Bytes
MobiFlightUnitTests/assets/MobiFlight/OutputConfig/VariableOutput/WriteXmlTest.1.xml
Binary file not shown.