From e7d8ff1e34ac967f775d8162e0848d57b1a5b186 Mon Sep 17 00:00:00 2001 From: haraldnilsen Date: Thu, 12 Oct 2023 13:01:39 +0200 Subject: [PATCH] :test_tube: Added a failing test for movieController Co-authored-by: Sindre Kjelsrud --- .../ControllerTests/MovieControllerTests.cs | 37 +++++++++++++++++++ .../cinemateketTests/cinemateketTests.csproj | 2 + 2 files changed, 39 insertions(+) create mode 100644 backend/cinemateketTests/ControllerTests/MovieControllerTests.cs diff --git a/backend/cinemateketTests/ControllerTests/MovieControllerTests.cs b/backend/cinemateketTests/ControllerTests/MovieControllerTests.cs new file mode 100644 index 0000000..5bd3d5c --- /dev/null +++ b/backend/cinemateketTests/ControllerTests/MovieControllerTests.cs @@ -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> _mockLogger; + private readonly Mock _mockDbContext; + + public MovieControllerTests() + { + _mockLogger = new Mock>(); + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "MovieDatabase") + .Options; + _mockDbContext = new Mock(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(result.Result); + } + +} \ No newline at end of file diff --git a/backend/cinemateketTests/cinemateketTests.csproj b/backend/cinemateketTests/cinemateketTests.csproj index 084a522..1b01a3a 100644 --- a/backend/cinemateketTests/cinemateketTests.csproj +++ b/backend/cinemateketTests/cinemateketTests.csproj @@ -9,12 +9,14 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive all +