public void MessageBus_SendMessage_Success() { string test_queue = $"test-queue-{Guid.NewGuid().ToString().ToLower().Replace("{", "").Replace("}", "")}"; IConfiguration config = GetConfiguration(); var cfg = config.GetSection("MsgBusConfig").Get <MsgBusConfig>(); IMessageBus msgBus = new Fineo.MessageBus.Azure.MessageBus(); IMessageBusParams msgBusParams = msgBus.CreateInitParams(); msgBusParams.Parameters["MessageQueue"] = test_queue; msgBusParams.Parameters["StorageAccountKey"] = cfg.StorageAccountKey; msgBusParams.Parameters["StorageAccountName"] = cfg.StorageAccountName; msgBusParams.Parameters["QueueEndpoint"] = cfg.QueueEndpoint; msgBus.Init(msgBusParams); var section = config.GetSection("TestMessage"); MessageBusDto busDto = config.GetSection("TestMessage").Get <MessageBusDto>(); busDto.Body = Guid.NewGuid().ToString(); msgBus.Send(busDto); MessageBusDto receivedDto = msgBus.ReadNext(); Assert.IsTrue(busDto.Equals(receivedDto)); msgBus.Delete(); }
public void Test_MessageBusDTO_Body() { string body = "test_body"; MessageBusDto msgBusDto = new MessageBusDto() { Body = body }; Assert.AreEqual(msgBusDto.Body, body); }
public void Test_MessageBusDTO_MessageID() { string messageId = "test_message_id"; MessageBusDto msgBusDto = new MessageBusDto() { MessageID = messageId }; Assert.AreEqual(msgBusDto.MessageID, messageId); }
public void Test_MessageBusDTO_SenderID() { string senderId = "test_sender_id"; MessageBusDto msgBusDto = new MessageBusDto() { SenderID = senderId }; Assert.AreEqual(msgBusDto.SenderID, senderId); }
public MessageBusDto ReadNext() { MessageBusDto result = null; CloudQueueMessage newMessage = queue.GetMessageAsync().Result; if (newMessage != null) { result = JsonConvert.DeserializeObject <MessageBusDto>(newMessage.AsString); if (string.IsNullOrEmpty(ID) || string.IsNullOrEmpty(result.ReceiverID) || ID.Equals(result.ReceiverID)) { queue.DeleteMessageAsync(newMessage); } } return(result); }
public void Test_MessageBusDTO_SerializeDeserialize() { string body = "test_body"; string messageId = "messageId"; string senderId = "senderId"; MessageBusDto msgBusDto = new MessageBusDto() { MessageID = messageId, SenderID = senderId, Body = body }; string serialized = JsonConvert.SerializeObject(msgBusDto); MessageBusDto deserialized = JsonConvert.DeserializeObject <MessageBusDto>(serialized); Assert.IsTrue(msgBusDto.Equals(deserialized)); }
public void Test_MessageBusDTO_TwoEqual() { string senderId = "test_sender_id"; string messageId = "test_message_id"; string body = "test_body"; MessageBusDto dto1 = new MessageBusDto() { SenderID = senderId, MessageID = messageId, Body = body }; MessageBusDto dto2 = new MessageBusDto() { SenderID = senderId, MessageID = messageId, Body = body }; Assert.IsTrue(dto1.Equals(dto2)); }
private void DownloadSECFiling(DownloadFiling msgDownload) { var secApi = new Fineo.SEC.Api.SECApi(); var submission = secApi.ArchivesEdgarDataCIKSubmission(msgDownload.CompanyCode, msgDownload.Filing); if (submission != null && submission.Files != null) { var filingDownloadedDto = new FilingDownloaded() { RegulatorCode = msgDownload.RegulatorCode, CompanyCode = msgDownload.CompanyCode, Filing = msgDownload.Filing }; var loopResult = Parallel.ForEach(submission.Files, f => { var subFile = secApi.ArchivesEdgarDataCIKSubmissionFile(msgDownload.CompanyCode, msgDownload.Filing, f.Name); if (subFile != null) { string blobPath = string.Format($"{msgDownload.RegulatorCode}\\{msgDownload.CompanyCode}\\{msgDownload.Filing}\\{subFile.Name}"); var newFile = new Fineo.Interfaces.FileInfo(); newFile.Path = blobPath; newFile.Content = subFile.Content.ToArray(); if (fileStorage.UploadAsync(newFile).Result) { filingDownloadedDto.Docs.Add(blobPath); } } }); var notificationDto = new MessageBusDto(); notificationDto.Body = JsonConvert.SerializeObject(filingDownloadedDto); notificationDto.MessageID = Guid.NewGuid().ToString(); msbOutNotification.Send(notificationDto); } }
public void Test_MessageBusDTO_TwoNotEqual_SenderID() { string senderId1 = "test_sender_id1"; string senderId2 = "test_sender_id2"; string messageId = "test_message_id"; string body = "test_body"; MessageBusDto dto1 = new MessageBusDto() { SenderID = senderId1, MessageID = messageId, Body = body }; MessageBusDto dto2 = new MessageBusDto() { SenderID = senderId2, MessageID = messageId, Body = body }; Assert.IsFalse(dto1.Equals(dto2)); }
public void Send(MessageBusDto msg) { CloudQueueMessage queueMsg = new CloudQueueMessage(JsonConvert.SerializeObject(msg)); queue.AddMessageAsync(queueMsg).Wait(); }