示例#1
0
        public void RunAsync_OtherException()
        {
            _Log.Setup(s => s.LogInformation("Posting stats."));
            const int    guildCount = 123;
            const long   botId      = 456;
            const string requestUri = "some/bot/url/456/stats";
            const string content    = "{\"guild_count\":123}";
            var          statPost   = new StatPost {
                GuildCountPropertyName = "guild_count", UrlStringFormat = "some/bot/url/{0}/stats", Token = "bot token"
            };
            var statPosts = new List <StatPost> {
                statPost
            };

            _StatWrapper.Setup(s => s.PostStatAsync(requestUri, content, "bot token")).ThrowsAsync(new Exception());
            Assert.That(async() => await _PostStatsHelper.RunAsync(guildCount, botId, statPosts), Throws.InstanceOf <Exception>());
            _Log.VerifyAll();
            _StatWrapper.VerifyAll();
        }
示例#2
0
        public async Task RunAsync()
        {
            _Log.Setup(s => s.LogInformation("Posting stats."));
            const int    guildCount = 123;
            const long   botId      = 456;
            const string requestUri = "some/bot/url/456/stats";
            const string content    = "{\"guild_count\":123}";
            var          statPost   = new StatPost {
                GuildCountPropertyName = "guild_count", UrlStringFormat = "some/bot/url/{0}/stats", Token = "bot token"
            };
            var statPosts = new List <StatPost> {
                statPost
            };

            _StatWrapper.Setup(s => s.PostStatAsync(requestUri, content, "bot token")).Returns(Task.CompletedTask);
            _Log.Setup(s => s.LogInformation("Posted stats."));
            var result = await _PostStatsHelper.RunAsync(guildCount, botId, statPosts);

            _Log.VerifyAll();
            _StatWrapper.VerifyAll();
            Assert.That(result, Is.TypeOf <NoContentResult>());
        }