コード例 #1
0
        public void Manager()
        {
            var expected = NamespaceManager.CreateFromConnectionString(connection);
            var bq       = new BusQueue(Guid.NewGuid().ToString(), expected, Substitute.For <IBusQueueClient>());

            Assert.AreEqual(expected, bq.Manager);
        }
コード例 #2
0
ファイル: LogListener.cs プロジェクト: nopjmp/LucoaBot
 public LogListener(DatabaseContext context, DiscordClient client,
                    BusQueue busQueue)
 {
     _context  = context;
     _client   = client;
     _busQueue = busQueue;
 }
コード例 #3
0
        public void Name()
        {
            var expected = Guid.NewGuid().ToString();
            var bq       = new BusQueue(expected, connection);

            Assert.AreEqual(expected, bq.Name);
        }
コード例 #4
0
ファイル: BusManager.cs プロジェクト: KDEGitHub/BusManager
 public bool IsInitQueue(string serviceName)
 {
     try
     {
         IBusQueue queue = GetQueue(serviceName);
         if (queue == null)
         {
             IServiceConfiguration config = _config.Services.FirstOrDefault(x => x.ServiceName == serviceName);
             if (config != null)
             {
                 queue = new BusQueue(_connection, config, _logger);
                 _queueList.Add(queue);
             }
             if (queue == null)
             {
                 return(false);
             }
         }
         return(queue.TryInit());
     }
     catch (Exception e)
     {
         _logger?.LogError(e, $"{_config.LocalIP} : {_config.ApplicationName}.{typeof(BusManager).FullName} : {e.Message}");
         return(false);
     }
 }
コード例 #5
0
ファイル: Bus.cs プロジェクト: mJaJksJ/MIET_Patterns_labs
        /// <summary>
        /// board passengers
        /// </summary>
        /// <param name="addingAmount">count of peoples in generating queue</param>
        public override List <Passenger.Passenger> BoardPassengers(int addingAmount)
        {
            List <Passenger.Passenger> busQueue = new BusQueue(addingAmount).GeneratePassengers(new BusPassengersBuilder());

            Passengers.AddRange(BoardBus.Instance().BoardPassenger(Passengers.Count, ref busQueue));
            return(busQueue);
        }
コード例 #6
0
        public async Task LockDuration()
        {
            var bq = new BusQueue(name, Configuration.ConnectionString);

            var lockDuration = await bq.LockDuration();

            Assert.AreEqual(TimeSpan.FromMinutes(1), lockDuration);
        }
コード例 #7
0
 public ServiceBus(ServiceBusConfig config)
 {
     IsRunning  = false;
     Config     = config;
     Production = Array.ConvertAll(config.Production, (x) => NamespaceManager.CreateFromConnectionString(x));
     Staging    = Array.ConvertAll(config.Staging, (x) => NamespaceManager.CreateFromConnectionString(x));
     BusQueue.SetMajorCritical(config.Major, config.Critical);
 }
コード例 #8
0
        public async Task ApproixmateMessageCount()
        {
            var bq = new BusQueue(name, Configuration.ConnectionString);

            var msg = new BrokeredMessage();

            await this.sender.Send(msg);

            var count = await bq.ApproixmateMessageCount();

            Assert.AreEqual(1, count);
        }
コード例 #9
0
        public async Task CreateIfNotExists()
        {
            var random = new Random();
            var name = string.Format("a{0}b", random.Next());
            var q = new BusQueue(name, connection);
            var result = await q.CreateIfNotExists();
            Assert.IsTrue(result);
            result = await q.CreateIfNotExists();
            Assert.IsFalse(result);

            await q.Delete();
        }
コード例 #10
0
        public void Setup()
        {
            var random = new Random();

            name = string.Format("a{0}b", random.Next());

            var bq = new BusQueue(name, Configuration.ConnectionString);

            bq.CreateIfNotExists().Wait();

            sender = new BusQueueSender(name, Configuration.ConnectionString);

            reciever = new BusQueueReciever(name, Configuration.ConnectionString);
        }
コード例 #11
0
        public async Task CreateIfNotExists()
        {
            var random = new Random();
            var name   = string.Format("a{0}b", random.Next());
            var q      = new BusQueue(name, Configuration.ConnectionString);
            var result = await q.CreateIfNotExists();

            Assert.IsTrue(result);
            result = await q.CreateIfNotExists();

            Assert.IsFalse(result);

            await q.Delete();
        }
コード例 #12
0
        public QrCodeListener(ILogger <QrCodeListener> logger,
                              IHttpClientFactory httpClientFactory, DiscordClient discordClient, BusQueue busQueue)
        {
            _logger            = logger;
            _httpClientFactory = httpClientFactory;
            _discordClient     = discordClient;
            _busQueue          = busQueue;

            _discordClient.MessageCreated += (_, e) =>
            {
                OnMessageReceived(e).Forget();
                return(Task.CompletedTask);
            };
        }
コード例 #13
0
        public async Task Delete()
        {
            var bq = new BusQueue(name, Configuration.ConnectionString);

            await bq.Delete();

            var result = await bq.CreateIfNotExists();

            Assert.IsTrue(result);

            await bq.Delete();

            result = await bq.CreateIfNotExists();

            Assert.IsTrue(result);

            await bq.Delete();
        }
コード例 #14
0
        public void TearDown()
        {
            var bq = new BusQueue(name, Configuration.ConnectionString);

            bq.Delete().Wait();
        }