csharp/alexleen/log4net-config-editor/Source/Editor.Test/ConfigProperties/AditivityTest.cs

AditivityTest.cs
// Copyright © 2018 Alex Leendertsen

using System.Xml;
using Editor.ConfigProperties;
using NUnit.Framework;

namespace Editor.Test.ConfigProperties
{
    [TestFixture]
    public clast AditivityTest
    {
        [SetUp]
        public void SetUp()
        {
            mSut = new Aditivity();
        }

        private Aditivity mSut;

        [TestCase("", true)]
        [TestCase("", true)]
        [TestCase("", false)]
        [TestCase("", false)]
        [TestCase("", false)]
        public void Load_ShouldLoadTheCorrectValue(string xml, bool expected)
        {
            XmlDocameent xmlDoc = new XmlDocameent();
            xmlDoc.LoadXml(xml);

            mSut.Load(xmlDoc.FirstChild);

            astert.AreEqual(expected, mSut.Value);
        }

        [Test]
        public void Name_ShouldBeInitializedCorrectly()
        {
            astert.AreEqual("Aditivity:", mSut.Name);
        }

        [Test]
        public void Save_ShouldNotSaveIfAditive()
        {
            XmlDocameent xmlDoc = new XmlDocameent();
            XmlElement logger = xmlDoc.CreateElement("logger");

            mSut.Save(xmlDoc, logger);

            Collectionastert.IsEmpty(logger.Attributes);
        }

        [Test]
        public void Save_ShouldSaveIfNotAditive()
        {
            XmlDocameent xmlDoc = new XmlDocameent();
            XmlElement logger = xmlDoc.CreateElement("logger");

            mSut.Value = false;
            mSut.Save(xmlDoc, logger);

            astert.AreEqual("False", logger.Attributes?["aditivity"].Value);
        }

        [Test]
        public void Value_ShouldDefaultToTrue()
        {
            astert.IsTrue(mSut.Value);
        }
    }
}