diff --git a/src/src/StevesBot.Webhook/YouTube/LastPostedStreamStore.cs b/src/src/StevesBot.Webhook/YouTube/LastPostedStreamStore.cs index a82c9a0..4ab8975 100644 --- a/src/src/StevesBot.Webhook/YouTube/LastPostedStreamStore.cs +++ b/src/src/StevesBot.Webhook/YouTube/LastPostedStreamStore.cs @@ -6,11 +6,13 @@ internal class LastPostedStreamStore : ILastPostedStreamStore public void SetValue(string value) { + ArgumentNullException.ThrowIfNull(value); _value = value; } public bool HasValue(string value) { + ArgumentNullException.ThrowIfNull(value); return _value.Equals(value, StringComparison.OrdinalIgnoreCase); } } \ No newline at end of file diff --git a/src/tests/StevesBot.Webhook.Tests/Unit/DiscordNotificationOptionsTests.cs b/src/tests/StevesBot.Webhook.Tests/Unit/DiscordNotificationOptionsTests.cs new file mode 100644 index 0000000..8b18ca5 --- /dev/null +++ b/src/tests/StevesBot.Webhook.Tests/Unit/DiscordNotificationOptionsTests.cs @@ -0,0 +1,28 @@ +namespace StevesBot.Webhook.Tests.Unit; + +public class DiscordNotificationOptionsTests +{ + [Fact] + public void Constructor_WhenCalled_ItShouldReturnInstance() + { + var options = new DiscordNotificationOptions(); + + options.ChannelId.Should().BeEmpty(); + } + + [Fact] + public void Constructor_WhenCalledWithProperties_ItShouldReturnInstance() + { + var channelId = "1234567890"; + var messageFormat = "New video uploaded: {VideoTitle}"; + + var options = new DiscordNotificationOptions + { + ChannelId = channelId, + MessageFormat = messageFormat + }; + + options.ChannelId.Should().Be(channelId); + options.MessageFormat.Should().Be(messageFormat); + } +} \ No newline at end of file diff --git a/src/tests/StevesBot.Webhook.Tests/Unit/LastPostedStreamStore.cs b/src/tests/StevesBot.Webhook.Tests/Unit/LastPostedStreamStore.cs new file mode 100644 index 0000000..90f1cd1 --- /dev/null +++ b/src/tests/StevesBot.Webhook.Tests/Unit/LastPostedStreamStore.cs @@ -0,0 +1,36 @@ +namespace StevesBot.Webhook.Tests.Unit; + +public class LastPostedStreamStoreTests +{ + [Fact] + public void SetValue_WhenCalledWithNull_ItShouldThrowArgumentNullException() + { + var store = new LastPostedStreamStore(); + + var act = () => store.SetValue(null!); + + act.Should().Throw(); + } + + [Fact] + public void HasValue_WhenCalledWithNull_ItShouldThrowArgumentNullException() + { + var store = new LastPostedStreamStore(); + + var act = () => store.HasValue(null!); + + act.Should().Throw(); + } + + + [Fact] + public void SetValueHasValue_WhenCalled_ItShouldStoreValue() + { + var store = new LastPostedStreamStore(); + var streamId = "test-stream-id"; + + store.SetValue(streamId); + + store.HasValue(streamId).Should().BeTrue(); + } +} \ No newline at end of file diff --git a/src/tests/StevesBot.Webhook.Tests/Unit/PubSubClientOptionsTests.cs b/src/tests/StevesBot.Webhook.Tests/Unit/PubSubClientOptionsTests.cs new file mode 100644 index 0000000..324b5f3 --- /dev/null +++ b/src/tests/StevesBot.Webhook.Tests/Unit/PubSubClientOptionsTests.cs @@ -0,0 +1,25 @@ +namespace StevesBot.Webhook.Tests.Unit; + +public class PubSubClientOptionsTests +{ + [Fact] + public void Constructor_WhenCalled_ItShouldReturnInstance() + { + var options = new PubSubClientOptions(); + + options.BaseUrl.Should().BeEmpty(); + } + + [Fact] + public void Constructor_WhenCalledWithProperties_ItShouldReturnInstance() + { + var baseUrl = "https://example.com"; + + var options = new PubSubClientOptions() + { + BaseUrl = baseUrl + }; + + options.BaseUrl.Should().Be(baseUrl); + } +} \ No newline at end of file diff --git a/src/tests/StevesBot.Webhook.Tests/Unit/SubscribeTaskTests.cs b/src/tests/StevesBot.Webhook.Tests/Unit/SubscribeTaskTests.cs new file mode 100644 index 0000000..463a642 --- /dev/null +++ b/src/tests/StevesBot.Webhook.Tests/Unit/SubscribeTaskTests.cs @@ -0,0 +1,33 @@ +namespace StevesBot.Webhook.Tests.Unit; + +public class SubscribeTaskTests +{ + [Fact] + public void Constructor_WhenCalled_ItShouldReturnInstance() + { + var task = new SubscribeTask(); + + task.CallbackUrl.Should().BeEmpty(); + task.TopicUrl.Should().BeEmpty(); + task.ExpiresAt.Should().Be(DateTime.MinValue); + } + + [Fact] + public void Constructor_WhenCalledWithProperties_ItShouldReturnInstance() + { + var callbackUrl = "https://example.com/callback"; + var topicUrl = "https://example.com/topic"; + var expiresAt = DateTime.UtcNow.AddDays(1); + + var task = new SubscribeTask + { + CallbackUrl = callbackUrl, + TopicUrl = topicUrl, + ExpiresAt = expiresAt + }; + + task.CallbackUrl.Should().Be(callbackUrl); + task.TopicUrl.Should().Be(topicUrl); + task.ExpiresAt.Should().Be(expiresAt); + } +} \ No newline at end of file diff --git a/src/tests/StevesBot.Webhook.Tests/Unit/SubscriptionOptionsTests.cs b/src/tests/StevesBot.Webhook.Tests/Unit/SubscriptionOptionsTests.cs new file mode 100644 index 0000000..f86d1e0 --- /dev/null +++ b/src/tests/StevesBot.Webhook.Tests/Unit/SubscriptionOptionsTests.cs @@ -0,0 +1,29 @@ +namespace StevesBot.Webhook.Tests.Unit; + +public class SubscriptionOptionsTests +{ + [Fact] + public void Constructor_WhenCalled_ItShouldReturnInstance() + { + var options = new SubscriptionOptions(); + + options.CallbackUrl.Should().BeEmpty(); + options.TopicUrl.Should().BeEmpty(); + } + + [Fact] + public void Constructor_WhenCalledWithProperties_ItShouldReturnInstance() + { + var callbackUrl = "https://example.com/callback"; + var topicUrl = "https://example.com/topic"; + + var options = new SubscriptionOptions + { + CallbackUrl = callbackUrl, + TopicUrl = topicUrl + }; + + options.CallbackUrl.Should().Be(callbackUrl); + options.TopicUrl.Should().Be(topicUrl); + } +} \ No newline at end of file diff --git a/src/tests/StevesBot.Webhook.Tests/Unit/YouTubeClientOptionsTests.cs b/src/tests/StevesBot.Webhook.Tests/Unit/YouTubeClientOptionsTests.cs new file mode 100644 index 0000000..2746534 --- /dev/null +++ b/src/tests/StevesBot.Webhook.Tests/Unit/YouTubeClientOptionsTests.cs @@ -0,0 +1,29 @@ +namespace StevesBot.Webhook.Tests.Unit; + +public class YouTubeClientOptionsTests +{ + [Fact] + public void Constructor_WhenCalled_ItShouldReturnInstance() + { + var options = new YouTubeClientOptions(); + + options.BaseUrl.Should().BeEmpty(); + options.ApiKey.Should().BeEmpty(); + } + + [Fact] + public void Constructor_WhenCalledWithProperties_ItShouldReturnInstance() + { + var baseUrl = "https://example.com"; + var apiKey = "test-api-key"; + + var options = new YouTubeClientOptions + { + BaseUrl = baseUrl, + ApiKey = apiKey + }; + + options.BaseUrl.Should().Be(baseUrl); + options.ApiKey.Should().Be(apiKey); + } +} \ No newline at end of file diff --git a/src/tests/StevesBot.Webhook.Tests/Usings.cs b/src/tests/StevesBot.Webhook.Tests/Usings.cs new file mode 100644 index 0000000..4617e08 --- /dev/null +++ b/src/tests/StevesBot.Webhook.Tests/Usings.cs @@ -0,0 +1,2 @@ +global using StevesBot.Webhook.YouTube; +global using StevesBot.Webhook.YouTube.Tasks; \ No newline at end of file