diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs index 1ddccd8..94d9975 100644 --- a/DiscordBot/Program.cs +++ b/DiscordBot/Program.cs @@ -23,7 +23,7 @@ public class Program { /// /// This is the Discord token from the bot - /// + /// private string? _discordToken; /// @@ -46,7 +46,7 @@ public class Program /// /// Init Program /// - public static Task Main(string[] args) + public static Task Main() { return new Program().MainAsync(); } diff --git a/DiscordBot/Services/SlashCommandsService.cs b/DiscordBot/Services/SlashCommandsService.cs index 6d7b071..38f6f99 100644 --- a/DiscordBot/Services/SlashCommandsService.cs +++ b/DiscordBot/Services/SlashCommandsService.cs @@ -271,7 +271,7 @@ public async Task WeatherSlashCommandAsync(IInteractionContextWrapper ctx, strin Program.Log("Message: " + message); if (success) { - DiscordEmbedBuilder embedMessage = new DiscordEmbedBuilder + DiscordEmbedBuilder embedMessage = new() { Title = $"{symbol} - {physicalCurrency} | ${message}", Description = $"Price of {symbol} - {physicalCurrency} is ${message}", diff --git a/DiscordBot/SlashCommands.cs b/DiscordBot/SlashCommands.cs index 0653983..5eb2829 100644 --- a/DiscordBot/SlashCommands.cs +++ b/DiscordBot/SlashCommands.cs @@ -61,7 +61,7 @@ public async Task PingSlashCommand(InteractionContext ctx) [Option("PhysicalCurrency", "The physical currency to compare against, e.g., USDT")] string physicalCurrency = "USDT") { - InteractionContextWrapper context = new InteractionContextWrapper(ctx); + InteractionContextWrapper context = new(ctx); await slashCommandsService.CryptoSlashCommandAsync(context, symbol, physicalCurrency); } } diff --git a/DiscordBotTests/ServiceTests/CryptoServiceTests.cs b/DiscordBotTests/ServiceTests/CryptoServiceTests.cs index bbbdba6..c4eaa35 100644 --- a/DiscordBotTests/ServiceTests/CryptoServiceTests.cs +++ b/DiscordBotTests/ServiceTests/CryptoServiceTests.cs @@ -31,8 +31,8 @@ public void Setup() public async Task GetCurrentCryptoPriceAsync_ReturnsCurrentPrice() { // Arrange - string symbol = "BTC"; - string physicalCurrency = "USDT"; + const string symbol = "BTC"; + const string physicalCurrency = "USDT"; const string jsonResponse = "{\"result\": [{\"last_price\": \"50000\"}]}"; const string expectedPrice = "50000"; _mockHttpService.Setup(x => x.GetResponseFromUrl(It.IsAny(), It.IsAny(), It.IsAny(), @@ -51,8 +51,8 @@ public async Task GetCurrentCryptoPriceAsync_ReturnsCurrentPrice() public async Task GetCurrentCryptoPriceAsync_ApiError_ReturnsErrorMessage() { // Arrange - string symbol = "BTC"; - string physicalCurrency = "USDT"; + const string symbol = "BTC"; + const string physicalCurrency = "USDT"; const string expectedErrorMessage = "API Error"; _mockHttpService.Setup(x => x.GetResponseFromUrl(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>>(), It.IsAny())) @@ -70,8 +70,8 @@ public async Task GetCurrentCryptoPriceAsync_ApiError_ReturnsErrorMessage() public async Task GetCurrentCryptoPriceAsync_InvalidJson_ReturnsFallbackMessage() { // Arrange - string symbol = "BTC"; - string physicalCurrency = "USDT"; + const string symbol = "BTC"; + const string physicalCurrency = "USDT"; const string invalidJsonResponse = "Invalid JSON"; _mockHttpService.Setup(x => x.GetResponseFromUrl(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>>(), It.IsAny())) @@ -89,8 +89,8 @@ public async Task GetCurrentCryptoPriceAsync_InvalidJson_ReturnsFallbackMessage( public async Task GetCurrentCryptoPriceAsync_MissingLastPrice_ReturnsFallbackMessage() { // Arrange - string symbol = "BTC"; - string physicalCurrency = "USDT"; + const string symbol = "BTC"; + const string physicalCurrency = "USDT"; const string jsonResponseMissingLastPrice = "{\"result\": [{}]}"; _mockHttpService.Setup(x => x.GetResponseFromUrl(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>>(), It.IsAny())) diff --git a/DiscordBotTests/ServiceTests/HttpServiceTests.cs b/DiscordBotTests/ServiceTests/HttpServiceTests.cs index f77918f..5570d1c 100644 --- a/DiscordBotTests/ServiceTests/HttpServiceTests.cs +++ b/DiscordBotTests/ServiceTests/HttpServiceTests.cs @@ -17,8 +17,8 @@ public void SetUp() _httpService = new HttpService(_mockRestClient.Object); } - private Mock _mockRestClient; - private IHttpService _httpService; + private Mock _mockRestClient = null!; + private IHttpService _httpService = null!; [Test] public async Task GetResponseFromURL_WithValidResponse_ReturnsSuccess() diff --git a/DiscordBotTests/ServiceTests/OpenAiServiceTests.cs b/DiscordBotTests/ServiceTests/OpenAiServiceTests.cs index aaebcdf..884cc4e 100644 --- a/DiscordBotTests/ServiceTests/OpenAiServiceTests.cs +++ b/DiscordBotTests/ServiceTests/OpenAiServiceTests.cs @@ -28,8 +28,8 @@ public void Setup() _openAiService = new OpenAiService(_mockHttpService.Object, configuration); } - private Mock _mockHttpService; - private OpenAiService? _openAiService; + private Mock _mockHttpService = null!; + private OpenAiService? _openAiService = null!; [Test] public async Task ChatGpt_WithValidApiKeyAndMessage_ReturnsSuccessAndResponse() diff --git a/DiscordBotTests/ServiceTests/OpenWeatherMapServiceTests.cs b/DiscordBotTests/ServiceTests/OpenWeatherMapServiceTests.cs index cecae4e..e984731 100644 --- a/DiscordBotTests/ServiceTests/OpenWeatherMapServiceTests.cs +++ b/DiscordBotTests/ServiceTests/OpenWeatherMapServiceTests.cs @@ -29,8 +29,8 @@ public void Setup() _openWeatherMapService = new OpenWeatherMapService(_mockHttpService.Object, configuration); } - private Mock _mockHttpService; - private OpenWeatherMapService _openWeatherMapService; + private Mock _mockHttpService = null!; + private OpenWeatherMapService _openWeatherMapService = null!; [Test] public void GetWeatherAsync_WithValidApiKeyAndCity_ReturnsSuccessAndWeatherData() diff --git a/DiscordBotTests/ServiceTests/SlashCommandsServiceTests.cs b/DiscordBotTests/ServiceTests/SlashCommandsServiceTests.cs index 02f90e0..802278a 100644 --- a/DiscordBotTests/ServiceTests/SlashCommandsServiceTests.cs +++ b/DiscordBotTests/ServiceTests/SlashCommandsServiceTests.cs @@ -10,13 +10,13 @@ namespace DiscordBotTests.ServiceTests; [Ignore("This test is not yet implemented. Currently, I don't know exactly how to properly mock the DiscordUser & DiscordChannel.")] public class SlashCommandsServiceTests { - private Mock _ctxMock; - private Mock _openAiServiceMock; - private Mock _openWeatherMapServiceMock; - private SlashCommandsService _slashCommandsService; - private Mock _watch2GetherServiceMock; - private Mock _cryptoServiceMock; - + private Mock _ctxMock = null!; + private Mock _openAiServiceMock = null!; + private Mock _openWeatherMapServiceMock = null!; + private SlashCommandsService _slashCommandsService = null!; + private Mock _watch2GetherServiceMock = null!; + private Mock _cryptoServiceMock = null!; + [SetUp] public void Setup() { diff --git a/DiscordBotTests/ServiceTests/Watch2GetherServiceTests.cs b/DiscordBotTests/ServiceTests/Watch2GetherServiceTests.cs index 6130811..acc22e5 100644 --- a/DiscordBotTests/ServiceTests/Watch2GetherServiceTests.cs +++ b/DiscordBotTests/ServiceTests/Watch2GetherServiceTests.cs @@ -29,8 +29,8 @@ public void Setup() _watch2GetherService = new Watch2GetherService(_mockHttpService.Object, configuration); } - private Watch2GetherService _watch2GetherService; - private Mock _mockHttpService; + private Watch2GetherService _watch2GetherService = null!; + private Mock _mockHttpService = null!; [Test] public async Task CreateRoom_SuccessfulRequest_ReturnsSuccessAndRoomUrl()