예제 #1
0
        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();
        }
예제 #2
0
        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);
        }
예제 #3
0
        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();
        }
예제 #4
0
        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
            }
        }