2016-12-16 14:30:47 -08:00
|
|
|
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)]
|
2017-01-09 15:44:14 -08:00
|
|
|
public async Task ValidateCreateTest(string url, ResolveFormat? quality, int? pageSize)
|
2016-12-16 14:30:47 -08:00
|
|
|
{
|
|
|
|
|
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",
|
2017-01-09 15:44:14 -08:00
|
|
|
Quality = ResolveFormat.AudioLow,
|
2016-12-16 14:30:47 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var response = await Client.PostAsync("/feed/create", MakeHttpContent(feed));
|
|
|
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
|
|
|
|
|
|
|
|
var id = await response.Content.ReadAsStringAsync();
|
|
|
|
|
Assert.NotNull(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|