🧪 Added a failing test for movieController
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
8c1ef192b1
commit
e7d8ff1e34
2 changed files with 39 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
|||
using Xunit;
|
||||
using Moq;
|
||||
using backend;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public class MovieControllerTests
|
||||
{
|
||||
private readonly Mock<ILogger<MovieController>> _mockLogger;
|
||||
private readonly Mock<MovieDbContext> _mockDbContext;
|
||||
|
||||
public MovieControllerTests()
|
||||
{
|
||||
_mockLogger = new Mock<ILogger<MovieController>>();
|
||||
var options = new DbContextOptionsBuilder<MovieDbContext>()
|
||||
.UseInMemoryDatabase(databaseName: "MovieDatabase")
|
||||
.Options;
|
||||
_mockDbContext = new Mock<MovieDbContext>(options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMovies_ValidQueryParams_ReturnsOk()
|
||||
{
|
||||
// Arrange
|
||||
var controller = new MovieController(_mockLogger.Object, _mockDbContext.Object);
|
||||
|
||||
// Act
|
||||
var result = controller.Get("Star Wars", "movie", "2021", "titleasc", 1, 5);
|
||||
|
||||
// Assert
|
||||
Assert.IsType<OkObjectResult>(result.Result);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue