<commit_before>using System;
using System.Linq;
using System.Threading.Tasks;
using Telegram.Bot.Requests;
using Telegram.Bot.Tests.Integ.Framework;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Xunit;

namespace Telegram.Bot.Tests.Integ.Polls
{
    [Collection(Constants.TestCollections.NativePolls)]
    [TestCaseOrderer(Constants.TestCaseOrderer, Constants.AssemblyName)]
    public class PollMessageTests : IClassFixture<PollTestsFixture>
    {
        private ITelegramBotClient BotClient => _fixture.BotClient;

        private readonly PollTestsFixture _classFixture;
        private readonly TestsFixture _fixture;

        public PollMessageTests(TestsFixture fixture, PollTestsFixture classFixture)
        {
            _fixture = fixture;
            _classFixture = classFixture;
        }

        [OrderedFact(FactTitles.ShouldSendPoll)]
        [Trait(Constants.MethodTraitName, Constants.TelegramBotApiMethods.SendPoll)]
        public async Task Should_Send_Poll()
        {
            string pollQuestion = "Poll question";
            string[] pollOptions =
            {
                "Poll option 1",
                "Poll option 2",
            };

            SendPollRequest sendPollRequest = new SendPollRequest(
                _fixture.SupergroupChat,
                pollQuestion,
                pollOptions
            );

            Message message = await BotClient.MakeRequestAsync(sendPollRequest);

            Assert.Equal(MessageType.Poll, message.Type);
            Assert.NotNull(message.Poll.Id);
            Assert.Equal(pollQuestion, message.Poll.Question);
            Assert.False(message.Poll.IsClosed);

            foreach (var pollOption in message.Poll.Options)
            {
                Assert.Contains(pollOption.Text, pollOptions, StringComparer.Ordinal);
            }

            _classFixture.PollMessage = message;
        }

        [OrderedFact(FactTitles.ShouldReceivePollStateUpdate)]
        public async Task Should_Receive_Poll_State_Update()
        {
            await _fixture.SendTestCaseNotificationAsync(
                "Any member of the test supergroup should vote in the poll"
            );

            Update update = (await _fixture.UpdateReceiver
                .GetUpdatesAsync(allowAnyone: true, updateTypes: UpdateType.Poll))
                .First();

            Poll poll = update.Poll;

            Assert.Equal(_classFixture.PollMessage.Poll.Id, poll.Id);
            Assert.False(poll.IsClosed);
        }

        [OrderedFact(FactTitles.ShouldStopPoll)]
        [Trait(Constants.MethodTraitName, Constants.TelegramBotApiMethods.StopPoll)]
        public async Task Should_Stop_Poll()
        {
            StopPollRequest stopPollRequest = new StopPollRequest(
                _classFixture.PollMessage.Chat,
                _classFixture.PollMessage.MessageId
            );

            Poll poll = await BotClient.MakeRequestAsync(stopPollRequest);

            Assert.Equal(_classFixture.PollMessage.Poll.Id, poll.Id);
            Assert.True(poll.IsClosed);
        }

        private static class FactTitles
        {
            public const string ShouldSendPoll = "Should send a poll";

            public const string ShouldReceivePollStateUpdate = "Should poll state update";

            public const string ShouldStopPoll = "Should stop the poll";
        }
    }
}<commit_msg>Make tests code style more explicit<commit_after>using System.Linq;
using System.Threading.Tasks;
using Telegram.Bot.Tests.Integ.Framework;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Xunit;

namespace Telegram.Bot.Tests.Integ.Polls
{
    [Collection(Constants.TestCollections.NativePolls)]
    [TestCaseOrderer(Constants.TestCaseOrderer, Constants.AssemblyName)]
    public class PollMessageTests : IClassFixture<PollTestsFixture>
    {
        private ITelegramBotClient BotClient => _fixture.BotClient;

        private readonly PollTestsFixture _classFixture;
        private readonly TestsFixture _fixture;

        public PollMessageTests(TestsFixture fixture, PollTestsFixture classFixture)
        {
            _fixture = fixture;
            _classFixture = classFixture;
        }

        [OrderedFact(FactTitles.ShouldSendPoll)]
        [Trait(Constants.MethodTraitName, Constants.TelegramBotApiMethods.SendPoll)]
        public async Task Should_Send_Poll()
        {
            Message message = await BotClient.SendPollAsync(
                /* chatId: */ _fixture.SupergroupChat,
                /* question: */ "Who shot first?",
                /* options: */ new[] { "Han Solo", "Greedo", "I don't care" }
            );

            Assert.Equal(MessageType.Poll, message.Type);
            Assert.NotEmpty(message.Poll.Id);
            Assert.False(message.Poll.IsClosed);

            Assert.Equal("Who shot first?", message.Poll.Question);
            Assert.Equal(3, message.Poll.Options.Length);
            Assert.Equal("<NAME>", message.Poll.Options[0].Text);
            Assert.Equal("Greedo", message.Poll.Options[1].Text);
            Assert.Equal("I don't care", message.Poll.Options[2].Text);

            Assert.All(message.Poll.Options, option => Assert.Equal(0, option.VoterCount));

            _classFixture.PollMessage = message;
        }

        [OrderedFact(FactTitles.ShouldReceivePollStateUpdate)]
        public async Task Should_Receive_Poll_State_Update()
        {
            await _fixture.SendTestCaseNotificationAsync(
                "Any member of the test supergroup should vote in the poll"
            );

            Update update = (await _fixture.UpdateReceiver
                .GetUpdatesAsync(allowAnyone: true, updateTypes: UpdateType.Poll))
                .First();

            Poll poll = update.Poll;

            Assert.Equal(_classFixture.PollMessage.Poll.Id, poll.Id);
            Assert.False(poll.IsClosed);
        }

        [OrderedFact(FactTitles.ShouldStopPoll)]
        [Trait(Constants.MethodTraitName, Constants.TelegramBotApiMethods.StopPoll)]
        public async Task Should_Stop_Poll()
        {
            Poll poll = await BotClient.StopPollAsync(
                /* chatId: */ _classFixture.PollMessage.Chat,
                /* messageId: */ _classFixture.PollMessage.MessageId
            );

            Assert.Equal(_classFixture.PollMessage.Poll.Id, poll.Id);
            Assert.True(poll.IsClosed);
        }

        private static class FactTitles
        {
            public const string ShouldSendPoll = "Should send a poll";

            public const string ShouldReceivePollStateUpdate = "Should poll state update";

            public const string ShouldStopPoll = "Should stop the poll";
        }
    }
}
{'fraction_non_alphanumeric': 0.08593054318788958, 'fraction_numerical': 0.0010388839418224993, 'mean_word_length': 2.29052734375, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5447874', 'n_tokens_mistral': 1884, 'n_tokens_neox': 1814, 'n_words': 348}