private static async Task <Chat> GetChat(TestsFixture testsFixture, string collectionName) { Chat chat; if (int.TryParse(ConfigurationProvider.TestConfigurations.RegularGroupMemberId, out int userId)) { chat = await testsFixture.BotClient.GetChatAsync(userId); } else { await testsFixture.UpdateReceiver.DiscardNewUpdatesAsync(); await testsFixture.SendTestCollectionNotificationAsync(collectionName, $"No value is set for `{nameof(ConfigurationProvider.TestConfigurations.RegularGroupMemberId)}` " + "in test settings.\n" + "An admin should forward a message from non-admin member or send his/her contact." ); chat = await testsFixture.GetChatFromAdminAsync(); } if (chat.Username is null) { await testsFixture.SendTestCollectionNotificationAsync(collectionName, $"[{chat.FirstName}](tg://user?id={chat.Id}) doesn't have a username.\n" + "❎ Failing tests..."); throw new ArgumentNullException(nameof(chat.Username), "Chat member doesn't have a username"); } return(chat); }