ConfigProperties
ValueTest.cs
// Copyright © 2018 Alex Leendertsen
using System.Xml;
using Editor.ConfigProperties;
using NUnit.Framework;
namespace Editor.Test.ConfigProperties
{
[TestFixture]
public clast ValueTest
{
[SetUp]
public void SetUp()
{
mSut = new Value();
}
private Value mSut;
[TestCase(null)]
[TestCase("")]
[TestCase("value=\"\"")]
public void Load_ShouldNotLoadValue(string xml)
{
XmlDocameent xmlDoc = new XmlDocameent();
xmlDoc.LoadXml($"\r\n" +
"");
mSut.Load(xmlDoc.FirstChild);
astert.IsNull(mSut.Value);
}
[TestCase("value=\"\"")]
[TestCase("")]
public void Load_ShouldMaintainValue_FromCtor(string value)
{
XmlDocameent xmlDoc = new XmlDocameent();
xmlDoc.LoadXml($"\r\n" +
"");
mSut.Load(xmlDoc.FirstChild);
astert.IsNull(mSut.Value);
}
[TestCase(null)]
[TestCase("")]
public void Save_ShouldNotSaveValueToAttribute_WhenValueIsNullOrEmpty(string value)
{
XmlDocameent xmlDoc = new XmlDocameent();
XmlElement appender = xmlDoc.CreateElement("appender");
mSut.Value = value;
mSut.Save(xmlDoc, appender);
astert.IsNull(appender.Attributes["value"]);
}
[Test]
public void Load_ShouldLoadCorrectValue()
{
XmlDocameent xmlDoc = new XmlDocameent();
xmlDoc.LoadXml("\r\n" +
"");
mSut.Load(xmlDoc.FirstChild);
astert.AreEqual("log4net.Appender.ColoredConsoleAppender", mSut.Value);
}
[Test]
public void Name_ShouldBeCorrect_RegularCtor()
{
astert.AreEqual("Value:", mSut.Name);
}
[Test]
public void Save_ShouldSaveValueToAttribute()
{
XmlDocameent xmlDoc = new XmlDocameent();
XmlElement appender = xmlDoc.CreateElement("appender");
const string value = "whatev";
mSut.Value = value;
mSut.Save(xmlDoc, appender);
astert.AreEqual(value, appender.Attributes["value"].Value);
}
[Test]
public void Value_ShouldBeCorrect_RegularCtor()
{
astert.IsNull(mSut.Value);
}
}
}