protected override void TraceDataCore(TraceEventCache eventCache, string source, TraceEventType eventType, int id, params object[] data)
        {
            SqlCommand cmd = GetTraceSqlCommand(eventCache, source, eventType, StringFormatter.FormatData(data));

            cmd.Connection.Open();
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();
        }
Beispiel #2
0
        public void FormatData_Call_OnDataFormattedEvent_EventReceived_OK()
        {
            // Arrange: Test data
            List <string> testData1 = new List <string>();

            testData1.Add("ATR423;39045;12932;14000;20151006213456789");
            testData1.Add("BCD123;10005;85890;12000;20151006213456789");
            testData1.Add("XYZ987;25059;75654;4000;20151006213456789");

            List <string> testData2 = new List <string>();

            testData2.Add("ATR423;39045;12932;14000;20151006213456789");
            testData2.Add("BCD123;10005;85890;12000;20151006213456789");
            testData2.Add("XYZ987;25059;75654;4000;20151006213456789");

            //Act:
            _uut.FormatData(testData1);
            //Act:
            _uut.FormatData(testData1);

            //Assert:
            Assert.That(_receivedEventArgs, Is.Not.Null);
        }
Beispiel #3
0
        /// <summary>
        /// If formatOrMessage is null retrurn null, else return StringFormatter.Format(data)
        /// </summary>
        /// <param name="value">The return value, usually null if the value couldn't be read</param>
        /// <param name="cache">The <see cref="TraceEventCache"/></param>
        /// <param name="source">The source of the logging event</param>
        /// <param name="eventType">The <see cref="TraceEventType"/> of the logging event</param>
        /// <param name="id">The id of the logging event</param>
        /// <param name="formatOrMessage">The format string or complete message</param>
        /// <param name="data">The array of objects</param>
        /// <returns>True if the value could be read</returns>
        public override bool TryGetValue(out object value, TraceEventCache cache, string source,
                                         TraceEventType eventType, int id, string formatOrMessage, object[] data)
        {
            if (string.IsNullOrEmpty(formatOrMessage))
            {
                value = StringFormatter.FormatData(data);
            }
            else
            {
                value = formatOrMessage;
            }

            return(true);
        }