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(); }
private IMessageBus InitMessageBus(string configName) { IMessageBus result = new Fineo.MessageBus.Azure.MessageBus(); IMessageBusParams msgBusParams = result.CreateInitParams(); IConfiguration config = GetConfiguration(); var section = config.GetSection(configName); msgBusParams.Parameters = section.GetChildren() .Select(item => new KeyValuePair <string, string>(item.Key, item.Value)) .ToDictionary(x => x.Key, x => x.Value); result.Init(msgBusParams); return(result); }
public void InitMessageBus_Success() { IConfiguration config = GetConfiguration(); var cfg = config.GetSection("MsgBusConfig").Get <MsgBusConfig>(); IMessageBus msgBus = new Fineo.MessageBus.Azure.MessageBus(); IMessageBusParams msgBusParams = msgBus.CreateInitParams(); msgBusParams.Parameters["MessageQueue"] = cfg.MessageQueue; msgBusParams.Parameters["StorageAccountKey"] = cfg.StorageAccountKey; msgBusParams.Parameters["StorageAccountName"] = cfg.StorageAccountName; msgBusParams.Parameters["QueueEndpoint"] = cfg.QueueEndpoint; msgBus.Init(msgBusParams); msgBus.Delete(); }
public void InitMessageBus_InvalidAccountName() { try { IConfiguration config = GetConfiguration(); var cfg = config.GetSection("MsgBusConfig_InvalidAccount").Get <MsgBusConfig>(); IMessageBus msgBus = new Fineo.MessageBus.Azure.MessageBus(); IMessageBusParams msgBusParams = msgBus.CreateInitParams(); msgBusParams.Parameters["MessageQueue"] = cfg.MessageQueue; msgBusParams.Parameters["StorageAccountKey"] = cfg.StorageAccountKey; msgBusParams.Parameters["StorageAccountName"] = cfg.StorageAccountName; msgBus.Init(msgBusParams); Assert.Fail("MessageBus initialized with invalud account"); } catch (Exception) { Assert.Pass(); // OK - exception is expected } }