From 845b1620ef51e72f664c23dcc8bc9905ec218238 Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Wed, 6 Jul 2022 11:13:57 -0500 Subject: [PATCH] added episodes controller unit test and integration test classes --- .../CharactersControllerIntegrationTests.cs | 2 -- .../EpisodesControllerIntegrationTests.cs | 28 +++++++++++++++++++ .../unitTests/EpisodesControllerUnitTests.cs | 18 ++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 server.tests/integrationTests/EpisodesControllerIntegrationTests.cs create mode 100644 server.tests/unitTests/EpisodesControllerUnitTests.cs diff --git a/server.tests/integrationTests/CharactersControllerIntegrationTests.cs b/server.tests/integrationTests/CharactersControllerIntegrationTests.cs index 9e1acd9..54280d0 100644 --- a/server.tests/integrationTests/CharactersControllerIntegrationTests.cs +++ b/server.tests/integrationTests/CharactersControllerIntegrationTests.cs @@ -3,8 +3,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Testing; using MongoDB.Bson; using server.Models; -using System.Collections; -using System.Collections.Generic; using System.Net; using System.Text.Json; diff --git a/server.tests/integrationTests/EpisodesControllerIntegrationTests.cs b/server.tests/integrationTests/EpisodesControllerIntegrationTests.cs new file mode 100644 index 0000000..3a2d5e7 --- /dev/null +++ b/server.tests/integrationTests/EpisodesControllerIntegrationTests.cs @@ -0,0 +1,28 @@ +using Microsoft.AspNetCore.Mvc.Testing; +using System.Text.Json; + +namespace server.tests.integrationTests +{ + public class EpisodesControllerIntegrationTests + { + private readonly HttpClient _client; + private readonly JsonSerializerOptions _serializerOptions; + private readonly string _endpoint; + + public EpisodesControllerIntegrationTests() + { + var webAppFactory = new WebApplicationFactory(); + + _client = webAppFactory.CreateDefaultClient(); + + _client.DefaultRequestHeaders.Add("x-api-version", "1"); + + _serializerOptions = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + _endpoint = "/api/episodes"; + } + } +} diff --git a/server.tests/unitTests/EpisodesControllerUnitTests.cs b/server.tests/unitTests/EpisodesControllerUnitTests.cs new file mode 100644 index 0000000..097e104 --- /dev/null +++ b/server.tests/unitTests/EpisodesControllerUnitTests.cs @@ -0,0 +1,18 @@ +using Moq; +using server.Controllers.v1; +using server.Persistence.Repositories; + +namespace server.tests.unitTests +{ + public class EpisodesControllerUnitTests + { + private readonly Mock _mockRepo; + private readonly EpisodesController _controller; + + public EpisodesControllerUnitTests() + { + _mockRepo = new Mock(); + _controller = new EpisodesController(_mockRepo.Object); + } + } +}