public Message(MB_Message messageRecord) : this() { if (messageRecord == null) { return; } Sender = messageRecord.Sender; Incoming = messageRecord.IsIncoming; try { LocalTimestamp = long.Parse(messageRecord.LocalTimestamp); } finally { } Body = messageRecord.Body; if (messageRecord.Recepients != null) { foreach (var recipient in messageRecord.Recepients.@string) { Recipients.AddRecipient(recipient); } } if (messageRecord.Attachments != null) { foreach (var attachment in messageRecord.Attachments) { Attachments.Add(new MessageAttachment(attachment)); } } }
public static void FillDefaultSender(this MB_Message message, string defaultSender) { if (message != null) { if (!string.IsNullOrEmpty(message.Sender)) { if (!string.IsNullOrEmpty(message.Sender.Trim())) { return; } } message.Sender = defaultSender; } }
public void SenderList() { var m = new MB_Message(); m.Sender = ""; m.FillDefaultSender("Thomas"); Assert.AreEqual("Thomas", m.Sender); m.Sender = " "; m.FillDefaultSender("Thomas"); Assert.AreEqual("Thomas", m.Sender); m.Sender = "Reed"; m.FillDefaultSender("Thomas"); Assert.AreEqual("Reed", m.Sender); }