Example #1
0
        public async void Test_NsfwExpiration()
        {
            var channel = new Mock <IMessageChannel>();

            _guildUser.Setup(user => user.RoleIds).Returns(new ulong[] { });
            var message = PrepareMessage(channel);

            var result = await _service.EnableNsfw(_guild.Object, channel.Object, _user.Object);

            Mock.Verify(channel);

            Assert.IsType <Success>(result);

            message.Setup(message => message.ModifyAsync(It.IsAny <Action <MessageProperties> >(), null))
            .Callback((Action <MessageProperties> callback, RequestOptions _) =>
            {
                var mock = new Mock <MessageProperties>();
                mock.SetupAllProperties();

                callback.Invoke(mock.Object);

                Assert.Equal("NSFW access request for Moq expired.", mock.Object.Content.Value);
            })
            .Returns(Task.CompletedTask)
            .Verifiable();

            _scheduler.AdvanceToNextTimer();
            Mock.Verify(message);
        }