1 |
782b6d38
|
Vojtěch Bartička
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2 |
|
|
using Models.Enums;
|
3 |
|
|
using Core.Entities;
|
4 |
|
|
using Serilog;
|
5 |
|
|
|
6 |
|
|
using System;
|
7 |
773d1205
|
schenkj
|
using System.Collections.Generic;
|
8 |
|
|
using System.Linq;
|
9 |
|
|
using System.Text;
|
10 |
|
|
using System.Threading.Tasks;
|
11 |
782b6d38
|
Vojtěch Bartička
|
using Microsoft.EntityFrameworkCore;
|
12 |
|
|
using AutoMapper;
|
13 |
|
|
using Core.MapperProfiles;
|
14 |
3899cd87
|
schenkj
|
using Microsoft.Extensions.Configuration;
|
15 |
|
|
using Core.Contexts;
|
16 |
773d1205
|
schenkj
|
|
17 |
782b6d38
|
Vojtěch Bartička
|
namespace Core.Services
|
18 |
773d1205
|
schenkj
|
{
|
19 |
782b6d38
|
Vojtěch Bartička
|
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 |
773d1205
|
schenkj
|
{
|
40 |
782b6d38
|
Vojtěch Bartička
|
public static ILogger GetLogger()
|
41 |
|
|
{
|
42 |
|
|
return new LoggerConfiguration().WriteTo.Console().CreateLogger(); /* logger */
|
43 |
|
|
}
|
44 |
773d1205
|
schenkj
|
}
|
45 |
3899cd87
|
schenkj
|
|
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 |
773d1205
|
schenkj
|
}
|