using AutoMapper;
using Dotnet.Samples.AspNetCore.WebApi.Controllers;
using Dotnet.Samples.AspNetCore.WebApi.Models;
using Dotnet.Samples.AspNetCore.WebApi.Repositories;
using Dotnet.Samples.AspNetCore.WebApi.Services;
using FluentValidation;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Moq;
namespace Dotnet.Samples.AspNetCore.WebApi.Tests.Utilities
{
///
/// A Mock is a dynamic test double that not only provides responses but
/// also records interactions. Mocks are pre‑programmed with expectations
/// (like “this method should be called once with these parameters”) and can
/// later verify that the expected calls occurred. Frameworks such as Moq
/// make it easy to set up and verify these interactions.
///
public static class PlayerMocks
{
///
/// Initializes mocks for PlayerController dependencies.
///
/// A tuple containing mocked service, logger, and validator.
public static (
Mock service,
Mock> logger,
Mock> validator
) InitControllerMocks()
{
var service = new Mock();
var logger = new Mock>();
var validator = new Mock>();
return (service, logger, validator);
}
///
/// Creates a mock IUrlHelper configured to return any string for Action calls.
///
/// A configured Mock of IUrlHelper.
public static Mock SetupUrlHelperMock()
{
var mock = new Mock();
mock.Setup(url => url.Action(It.IsAny())).Returns(It.IsAny());
return mock;
}
///
/// Initializes mocks for PlayerService dependencies.
///
/// Optional cache value to return from memory cache.
/// The environment name (defaults to "Development").
/// A tuple containing mocked repository, logger, cache, mapper, and environment.
public static (
Mock repository,
Mock> logger,
Mock memoryCache,
Mock mapper,
Mock environment
) InitServiceMocks(object? cacheValue = null, string environmentName = "Development")
{
var repository = new Mock();
var logger = new Mock>();
var memoryCache = SetupMemoryCacheMock(cacheValue ?? It.IsAny