/// <summary>
        /// Generates a formatted message for HergBot Markup Language logging
        /// </summary>
        /// <param name="timestamp">The logs timestamp</param>
        /// <param name="threadName">The name of the thread the message is logged from</param>
        /// <param name="methodName">The name of the method logging the message</param>
        /// <param name="type">The label for the type of log message</param>
        /// <param name="message">The log message</param>
        /// <returns>A formatted HBML element string for logging</returns>
        public string GenerateLogMessage(string timestamp, string threadName, string methodName, string type, string message)
        {
            // Build the element for the log entry
            HbmlElement logElement = new HbmlElement(LOG_ELEMENT_LABEL);

            logElement.AddElement(LOG_DATE_LABEL, timestamp);
            logElement.AddElement(LOG_TYPE_LABEL, type);
            logElement.AddElement(LOG_THREAD_NAME_LABEL, threadName);
            logElement.AddElement(LOG_METHOD_NAME_LABEL, methodName);
            logElement.AddElement(LOG_MESSAGE_LABEL, message);
            return(logElement.ToString());
        }
Exemplo n.º 2
0
        public void AddElement()
        {
            _testElement.AddElement(TEST_LABEL, TEST_VALUE);
            HbmlElement child = _testElement.GetChildElement(TEST_LABEL);

            Assert.IsNotNull(child);
        }
Exemplo n.º 3
0
        public void ToString_MultiLayered()
        {
            HbmlElement childElement = new HbmlElement(TEST_LABEL, TEST_VALUE);

            childElement.AddElement(TEST_LABEL, TEST_VALUE);
            _testElement.Value = TEST_VALUE;
            _testElement.AddAttribute(TEST_ATTRIBUTE_NAME, TEST_ATTRIBUTE_VALUE);
            _testElement.AddElement(childElement);
            string expected = $"<{TEST_LABEL} {TEST_ATTRIBUTE_NAME}=\"{TEST_ATTRIBUTE_VALUE}\">\n    {TEST_VALUE}\n    <{TEST_LABEL}>\n        {TEST_VALUE}\n        <{TEST_LABEL}>{TEST_VALUE}</{TEST_LABEL}>\n    </{TEST_LABEL}>\n</{TEST_LABEL}>";

            Assert.AreEqual(expected, _testElement.ToString());
        }