예제 #1
0
        public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "prefixDictionary")] HttpRequest req, ILogger log)
        {
            var connectionString = Environment.GetEnvironmentVariable("TrendingGiphyBotConnectionString");
            var logWrapper       = new LoggerWrapper(log);

            using (var context = new TrendingGiphyBotContext(connectionString))
            {
                var getPrefixDictionaryHelper = new GetPrefixDictionaryHelper(logWrapper, context);
                return(await getPrefixDictionaryHelper.RunAsync());
            }
        }
예제 #2
0
        public async Task RunAsync()
        {
            _Log.Setup(s => s.LogInformation("Getting prefix dictionary."));
            var prefixDictionary = new Dictionary <decimal, string> {
                { 123, "!" }, { 456, "^" }
            };

            _Context.Setup(s => s.GetPrefixDictionary()).ReturnsAsync(prefixDictionary);
            _Log.Setup(s => s.LogInformation($"Got {prefixDictionary.Count} prefixes."));
            var result = await _GetPrefixDictionaryHelper.RunAsync();

            _Log.VerifyAll();
            _Context.VerifyAll();
            var okObjectResult = result as OkObjectResult;

            Assert.That(okObjectResult, Is.Not.Null);
            Assert.That(okObjectResult.Value, Is.EqualTo(prefixDictionary));
        }