1
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2
|
using Models.Enums;
|
3
|
using Core.Entities;
|
4
|
using Serilog;
|
5
|
|
6
|
using System;
|
7
|
using System.Collections.Generic;
|
8
|
using System.Linq;
|
9
|
using System.Text;
|
10
|
using System.Threading.Tasks;
|
11
|
using Microsoft.EntityFrameworkCore;
|
12
|
using AutoMapper;
|
13
|
using Core.MapperProfiles;
|
14
|
using Microsoft.Extensions.Configuration;
|
15
|
using Core.Contexts;
|
16
|
|
17
|
namespace Core.Services
|
18
|
{
|
19
|
public class Utils
|
20
|
{
|
21
|
}
|
22
|
|
23
|
public static class TestingMapper
|
24
|
{
|
25
|
public static IMapper GetMapper()
|
26
|
{
|
27
|
var mapperConfig = new MapperConfiguration(cfg =>
|
28
|
{
|
29
|
cfg.AddProfile<DocumentProfileEF>();
|
30
|
cfg.AddProfile<UserProfileEF>();
|
31
|
cfg.AddProfile<TagProfileEF>();
|
32
|
});
|
33
|
|
34
|
IMapper mapper = mapperConfig.CreateMapper();
|
35
|
return mapper;
|
36
|
}
|
37
|
}
|
38
|
public static class TestingLogger
|
39
|
{
|
40
|
public static ILogger GetLogger()
|
41
|
{
|
42
|
return new LoggerConfiguration().WriteTo.Console().CreateLogger(); /* logger */
|
43
|
}
|
44
|
}
|
45
|
|
46
|
public static class TestingUserService
|
47
|
{
|
48
|
private static readonly IConfiguration configuration = new ConfigurationBuilder().Build();
|
49
|
|
50
|
public static IUserService GetUserService()
|
51
|
{
|
52
|
return new UserServiceEF(new DatabaseContext(configuration), TestingLogger.GetLogger(), TestingMapper.GetMapper());
|
53
|
}
|
54
|
}
|
55
|
}
|