39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using Bogus;
|
|
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using DigitalData.UserManager.Domain.Entities;
|
|
using EnvelopeGenerator.Application.Envelopes.Commands;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using MediatR;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace EnvelopeGenerator.Tests.Application;
|
|
|
|
public class TestBase : Faker
|
|
{
|
|
protected Fake.Host Host;
|
|
|
|
protected User User => Host.User;
|
|
|
|
protected IMediator Mediator => Host.Mediator;
|
|
|
|
protected CreateEnvelopeCommand FakeCreateEnvelopeCommand => this.CreateEnvelopeCommand(Host.User.Id);
|
|
|
|
protected Envelope FakeEnvelope => this.CreateEnvelope(Host.User.Id);
|
|
|
|
protected IRepository<T> GetRepository<T>() where T : class => Host.GetRepository<T>();
|
|
|
|
protected IRepository Repository => Host.Services.GetRequiredService<IRepository>();
|
|
|
|
[SetUp]
|
|
public virtual async Task Setup()
|
|
{
|
|
Host = Fake.CreateHost();
|
|
await Host.AddSamples();
|
|
}
|
|
|
|
[TearDown]
|
|
public virtual void TearDown()
|
|
{
|
|
Host.Dispose();
|
|
}
|
|
} |