Exemple #1
0
        public void ToString_ReturnsJson()
        {
            const string        requestId = "a";
            const MessageMethod method    = MessageMethod.GetOperationClaims;
            const MessageType   type      = MessageType.Request;
            const TaskState     state     = TaskState.Executing;

            var now = DateTimeOffset.UtcNow;

            var logMessage = new TaskLogMessage(now, requestId, method, type, state);

            var message = VerifyOuterMessageAndReturnInnerMessage(logMessage, now, "task");

            Assert.Equal(5, message.Count);

            var actualRequestId     = message.Value <string>("request ID");
            var actualMethod        = Enum.Parse(typeof(MessageMethod), message.Value <string>("method"));
            var actualType          = Enum.Parse(typeof(MessageType), message.Value <string>("type"));
            var actualState         = Enum.Parse(typeof(TaskState), message.Value <string>("state"));
            var actualCurrentTaskId = message.Value <int>("current task ID");

            Assert.Equal(requestId, actualRequestId);
            Assert.Equal(method, actualMethod);
            Assert.Equal(type, actualType);
            Assert.Equal(state, actualState);
            Assert.Equal(Task.CurrentId, actualCurrentTaskId);
        }
Exemple #2
0
            /// <summary>
            /// Logs the message.
            /// </summary>
            /// <param name="messageType">Type of the message.</param>
            /// <param name="message">The message.</param>
            /// <param name="category">The category.</param>
            /// <returns></returns>
            public TaskLogMessage LogMessage(TaskLogMessage.MessageTypeSpecifier messageType, string message, string category = null)
            {
                var newMessage = new TaskLogMessage {
                    MessageType = messageType, Message = message, Category = category
                };

                Trace.WriteLine(newMessage.ToString());

                _Messages.Add(newMessage);

                return(newMessage);
            }
Exemple #3
0
 /// <summary>
 /// Create a logmessage
 /// </summary>
 /// <param name="title">The title.</param>
 /// <param name="text">The text.</param>
 private void CreateLogmessage(string title, string text)
 {
     TaskLogMessage logMessage = new TaskLogMessage(this, title, text);
     if (!logMessages.Contains(logMessage))
     {
         logMessages.Add(logMessage);
     }
 }