示例#1
0
 public void RemoveRefsTo(AppenderModel appenderModel)
 {
     //Remove all appender refs
     foreach (XmlNode refModel in XmlUtilities.FindAppenderRefs(Log4NetNode, appenderModel.Name))
     {
         refModel.ParentNode?.RemoveChild(refModel);
     }
 }
示例#2
0
        public void TryCreate_ShouldReturnTrue_ForKnownAppenders(string xml, Type expectedModelType)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xml);

            Assert.IsTrue(AppenderModel.TryCreate(xmlDoc.FirstChild.FirstChild, xmlDoc.FirstChild, out AppenderModel _));
        }
示例#3
0
        public void TryCreate_ShouldReturnCorrectType(string xml, Type expectedModelType)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xml);

            AppenderModel.TryCreate(xmlDoc.FirstChild.FirstChild, xmlDoc.FirstChild, out AppenderModel model);

            Assert.IsInstanceOf(expectedModelType, model);
        }
示例#4
0
        public void TryCreate_ShouldReturnFalse_ForUnknownAppenders()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml("<log4net>" +
                           "<appender>" +
                           "</appender>" +
                           "</log4net>");

            Assert.IsFalse(AppenderModel.TryCreate(xmlDoc.FirstChild.FirstChild, xmlDoc.FirstChild, out AppenderModel _));
        }
示例#5
0
        public void Name_ShouldBeNull_WhenNodeNameIsNonExistent()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml("<log4net>" +
                           "<appender>" +
                           "</appender>" +
                           "</log4net>");

            AppenderModel sut = new AppenderModel(AppenderDescriptor.Async, xmlDoc.FirstChild.FirstChild, 0);

            Assert.IsNull(sut.Name);
        }
示例#6
0
        public void HasReferences_ShouldReturnCorrectValue(int incomingRefs, bool expectedValue)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml("<log4net>" +
                           "<appender>" +
                           "</appender>" +
                           "</log4net>");

            AppenderModel sut = new AppenderModel(AppenderDescriptor.Async, xmlDoc.FirstChild.FirstChild, incomingRefs);

            Assert.AreEqual(expectedValue, sut.HasReferences);
        }
示例#7
0
        public void Ctor_ShouldAssignIncomingReferences()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml("<log4net>" +
                           "<appender>" +
                           "</appender>" +
                           "</log4net>");

            AppenderModel sut = new AppenderModel(AppenderDescriptor.Async, xmlDoc.FirstChild.FirstChild, 1);

            Assert.AreEqual(1, sut.IncomingReferences);
        }
示例#8
0
        private void LoadPossibleReferences()
        {
            XmlNodeList availableRefs = mConfiguration.Log4NetNode.SelectNodes("appender");

            foreach (XmlNode appender in availableRefs)
            {
                string name = appender.Attributes["name"].Value;

                if (Equals(appender, mConfiguration.OriginalNode) || RefsCollection.Any(@ref => Equals(@ref.Name, name)))
                {
                    continue;
                }

                if (AppenderModel.TryCreate(appender, mConfiguration.Log4NetNode, out AppenderModel appenderModel))
                {
                    RefsCollection.Add(appenderModel);
                }
            }
        }
        private bool LoadAppenders()
        {
            //Only selects appenders under this log4net element
            XmlNodeList appenderList = Log4NetNode.SelectNodes("appender");

            bool unrecognized = false;

            foreach (XmlNode node in appenderList)
            {
                if (AppenderModel.TryCreate(node, Log4NetNode, out AppenderModel model))
                {
                    mMutableChildren.Add(model);
                }
                else
                {
                    unrecognized = true;
                }
            }

            return(unrecognized);
        }
示例#10
0
        public void Name_ShouldBeNull_WhenNodeIsNull()
        {
            AppenderModel sut = new AppenderModel(AppenderDescriptor.Async, null, 0);

            Assert.IsNull(sut.Name);
        }
 public void Convert_ShouldReturnVisible(AppenderModel model, string param)
 {
     Assert.AreEqual(Visibility.Visible, mSut.Convert(model, null, param, null));
 }