public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = "channels/{channelid:decimal}")] HttpRequest req, decimal channelId, ILogger log)
        {
            var container = await req.Body.ReadToEndAsync <ChannelConfigContainer>();

            var connectionString = Environment.GetEnvironmentVariable("TopTwitchClipBotConnectionString");
            var logWrapper       = new LoggerWrapper(log);
            ChannelConfigContainer result;

            using (var context = new TopTwitchClipBotContext(connectionString))
            {
                var helper = new PostChannelConfigHelper(logWrapper, context);
                result = await helper.PostChannelConfigAsync(channelId, container);
            }
            return(new OkObjectResult(result));
        }
Exemple #2
0
        public async Task PostChannelConfigAsync()
        {
            const int channelId = 123;

            _Log.Setup(s => s.LogInformation($"Posting channel config for channel '{channelId}'."));
            var inputContainer  = new ChannelConfigContainer();
            var outputContainer = new ChannelConfigContainer();

            _Context.Setup(s => s.SetChannelConfigAsync(channelId, inputContainer)).ReturnsAsync(outputContainer);
            _Log.Setup(s => s.LogInformation($"Posted channel config for channel '{channelId}'."));
            var result = await _Helper.PostChannelConfigAsync(channelId, inputContainer);

            _Log.VerifyAll();
            _Context.VerifyAll();
            Assert.That(result, Is.EqualTo(outputContainer));
        }