public async Task Process_ProcessesRenewLock()
        {
            ILogger         fakeLogger         = Substitute.For <ILogger>();
            ILoggerProvider fakeLoggerProvider = Substitute.For <ILoggerProvider>();

            fakeLoggerProvider.CreateLogger(Arg.Any <string>()).Returns(fakeLogger);
            var processor  = new ManagementRequestProcessor(fakeLoggerProvider);
            var lockTokens = new Guid[] { Guid.NewGuid(), Guid.NewGuid() };
            var request    = new Message(new Map {
                ["lock-tokens"] = lockTokens
            })
            {
                ApplicationProperties = new Amqp.Framing.ApplicationProperties
                {
                    ["operation"] = "com.microsoft:renew-lock"
                }
            };

            Message response = await TestAmqpHost.ProcessManagementRequestAsync(request, processor);

            var expirations = (response.Body as Map)?["expirations"] as DateTime[];

            response.ApplicationProperties["statusCode"].ShouldBe(200);
            expirations.Length.ShouldBe(2);
            fakeLogger.Received(1).Log(
                LogLevel.Debug,
                Arg.Any <EventId>(),
                Arg.Is <FormattedLogValues>(a => a.ToString() == "com.microsoft:renew-lock applied to 2 lock token(s)."),
                Arg.Any <Exception>(),
                Arg.Any <Func <FormattedLogValues, Exception, string> >());
        }
        public async Task Process_ReturnsSuccessStatusCodeInResponse()
        {
            var processor = new ManagementRequestProcessor(Substitute.For <ILoggerProvider>());
            var request   = new Message();

            Message response = await TestAmqpHost.ProcessManagementRequestAsync(request, processor);

            response.ApplicationProperties["statusCode"].ShouldBe(200);
        }
        public async Task Process_LogsUnsupportedOperation(string operation)
        {
            ILogger         fakeLogger         = Substitute.For <ILogger>();
            ILoggerProvider fakeLoggerProvider = Substitute.For <ILoggerProvider>();

            fakeLoggerProvider.CreateLogger(Arg.Any <string>()).Returns(fakeLogger);
            var processor = new ManagementRequestProcessor(fakeLoggerProvider);
            var request   = new Message
            {
                ApplicationProperties = new Amqp.Framing.ApplicationProperties
                {
                    ["operation"] = operation
                }
            };

            await TestAmqpHost.ProcessManagementRequestAsync(request, processor);

            fakeLogger.Received(1).Log(
                LogLevel.Debug,
                Arg.Any <EventId>(),
                Arg.Is <FormattedLogValues>(a => a.ToString() == $"Unsupported operation {operation}."),
                Arg.Any <Exception>(),
                Arg.Any <Func <FormattedLogValues, Exception, string> >());
        }