tests: more tests
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using StevesBot.Library.Discord.Rest;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace StevesBot.Webhook.Tests.Unit;
|
||||
|
||||
public class VerifySubscriptionHandlerTests
|
||||
{
|
||||
private readonly Mock<IOptions<SubscriptionOptions>> _mockSubOptions = new();
|
||||
private readonly Mock<ILogger<Program>> _mockLogger = new();
|
||||
private readonly ConcurrentQueue<SubscribeTask> _subscriptionQueue = new();
|
||||
|
||||
[Fact]
|
||||
public void Handle_WhenModeIsDenied_ItShouldReturnBadRequest()
|
||||
{
|
||||
var result = Handle("denied", "topic");
|
||||
|
||||
result.Should().BeOfType<BadRequest<string>>();
|
||||
}
|
||||
|
||||
private IResult Handle(string mode, string topic, string? reason = null, string? challenge = null, string? leaseSeconds = null)
|
||||
{
|
||||
return VerifySubscriptionHandler.Handle(
|
||||
mode,
|
||||
topic,
|
||||
reason,
|
||||
challenge,
|
||||
leaseSeconds,
|
||||
_mockSubOptions.Object,
|
||||
_mockLogger.Object,
|
||||
_subscriptionQueue
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
global using System.Collections.Concurrent;
|
||||
global using System.Net;
|
||||
global using System.Text;
|
||||
|
||||
global using Microsoft.AspNetCore.Http;
|
||||
global using Microsoft.AspNetCore.Http.HttpResults;
|
||||
global using Microsoft.Extensions.Logging;
|
||||
global using Microsoft.Extensions.Options;
|
||||
|
||||
global using Moq;
|
||||
|
||||
global using RichardSzalay.MockHttp;
|
||||
|
||||
global using StevesBot.Library.Discord.Rest;
|
||||
global using StevesBot.Library.Discord.Rest.Requests;
|
||||
global using StevesBot.Webhook.YouTube;
|
||||
global using StevesBot.Webhook.YouTube.Data;
|
||||
global using StevesBot.Webhook.YouTube.Tasks;
|
||||
global using StevesBot.Webhook.YouTube.Handlers;
|
||||
global using StevesBot.Webhook.YouTube.Tasks;
|
||||
Reference in New Issue
Block a user