mirror of
https://github.com/alex289/CleanArchitecture.git
synced 2025-06-30 02:31:08 +00:00
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using CleanArchitecture.Application.Queries.Tenants.GetAll;
|
|
using CleanArchitecture.Application.SortProviders;
|
|
using CleanArchitecture.Domain.Entities;
|
|
using CleanArchitecture.Domain.Interfaces.Repositories;
|
|
using MockQueryable.NSubstitute;
|
|
using NSubstitute;
|
|
|
|
namespace CleanArchitecture.Application.Tests.Fixtures.Queries.Tenants;
|
|
|
|
public sealed class GetAllTenantsTestFixture : QueryHandlerBaseFixture
|
|
{
|
|
public GetAllTenantsQueryHandler QueryHandler { get; }
|
|
private ITenantRepository TenantRepository { get; }
|
|
|
|
public GetAllTenantsTestFixture()
|
|
{
|
|
TenantRepository = Substitute.For<ITenantRepository>();
|
|
var sortingProvider = new TenantViewModelSortProvider();
|
|
|
|
QueryHandler = new GetAllTenantsQueryHandler(TenantRepository, sortingProvider);
|
|
}
|
|
|
|
public Tenant SetupTenant(bool deleted = false)
|
|
{
|
|
var tenant = new Tenant(Guid.NewGuid(), "Tenant 1");
|
|
|
|
if (deleted)
|
|
{
|
|
tenant.Delete();
|
|
}
|
|
|
|
var tenantList = new List<Tenant> { tenant }.BuildMock();
|
|
TenantRepository.GetAllNoTracking().Returns(tenantList);
|
|
|
|
return tenant;
|
|
}
|
|
} |