mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Podsync.Services;
|
|
using Podsync.Services.Resolver;
|
|
using Xunit;
|
|
|
|
namespace Podsync.Tests.Controllers
|
|
{
|
|
public class FeedControllerTests : TestServer<Startup>
|
|
{
|
|
[Fact]
|
|
public async Task ValidateCreateNullTest()
|
|
{
|
|
var response = await Client.PostAsync("/feed/create", new StringContent("", Encoding.UTF8, "application/json"));
|
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null, null)]
|
|
[InlineData("a", null, null)]
|
|
[InlineData("http://youtube.com", null, 0)]
|
|
[InlineData("http://youtube.com", null, 25)]
|
|
[InlineData("http://youtube.com", null, 151)]
|
|
public async Task ValidateCreateTest(string url, ResolveType? quality, int? pageSize)
|
|
{
|
|
var feed = new CreateFeedRequest
|
|
{
|
|
Url = url,
|
|
Quality = quality,
|
|
PageSize = pageSize
|
|
};
|
|
|
|
var response = await Client.PostAsync("/feed/create", MakeHttpContent(feed));
|
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task CreateFeedTest()
|
|
{
|
|
var feed = new CreateFeedRequest
|
|
{
|
|
Url = "https://www.youtube.com/channel/UCKy1dAqELo0zrOtPkf0eTMw",
|
|
Quality = ResolveType.AudioLow,
|
|
};
|
|
|
|
var response = await Client.PostAsync("/feed/create", MakeHttpContent(feed));
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
|
|
var id = await response.Content.ReadAsStringAsync();
|
|
Assert.NotNull(id);
|
|
}
|
|
}
|
|
} |