public void RemoveRefsTo(AppenderModel appenderModel) { //Remove all appender refs foreach (XmlNode refModel in XmlUtilities.FindAppenderRefs(Log4NetNode, appenderModel.Name)) { refModel.ParentNode?.RemoveChild(refModel); } }
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 _)); }
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); }
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 _)); }
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); }
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); }
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); }
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); }
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)); }