Exemplo n.º 1
0
        public async Task GetQueueLength()
        {
            MockApplicationLifetime  appLifetime  = new MockApplicationLifetime();
            MockReliableStateManager stateManager = new MockReliableStateManager();

            IReliableQueue <DeviceEventSeries> queue =
                await stateManager.GetOrAddAsync <IReliableQueue <DeviceEventSeries> >(DataService.EventQueueName);

            using (ITransaction tx = stateManager.CreateTransaction())
            {
                await queue.EnqueueAsync(tx, new DeviceEventSeries("", new DeviceEvent[0]));
            }

            DevicesController target = new DevicesController(stateManager, appLifetime);
            IActionResult     result = await target.GetQueueLengthAsync();

            Assert.True(result is OkObjectResult);
            long actual = (long)((OkObjectResult)result).Value;

            Assert.Equal(1, actual);
        }