Revize 782b6d38
Přidáno uživatelem Vojtěch Bartička před asi 3 roky(ů)
Backend/Backend.sln | ||
---|---|---|
7 | 7 |
EndProject |
8 | 8 |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "Models\Models.csproj", "{03BFE675-EE7F-4493-8682-6D13EEEABD4F}" |
9 | 9 |
EndProject |
10 |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{EE92204E-BFD8-473F-BBBC-51E975BF6937}" |
|
10 |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{EE92204E-BFD8-473F-BBBC-51E975BF6937}" |
|
11 |
EndProject |
|
12 |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BackendTesting", "BackendTesting\BackendTesting.csproj", "{516D3F60-5760-445B-9B0C-B2108046D9D4}" |
|
11 | 13 |
EndProject |
12 | 14 |
Global |
13 | 15 |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
... | ... | |
27 | 29 |
{EE92204E-BFD8-473F-BBBC-51E975BF6937}.Debug|Any CPU.Build.0 = Debug|Any CPU |
28 | 30 |
{EE92204E-BFD8-473F-BBBC-51E975BF6937}.Release|Any CPU.ActiveCfg = Release|Any CPU |
29 | 31 |
{EE92204E-BFD8-473F-BBBC-51E975BF6937}.Release|Any CPU.Build.0 = Release|Any CPU |
32 |
{516D3F60-5760-445B-9B0C-B2108046D9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
33 |
{516D3F60-5760-445B-9B0C-B2108046D9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
34 |
{516D3F60-5760-445B-9B0C-B2108046D9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
35 |
{516D3F60-5760-445B-9B0C-B2108046D9D4}.Release|Any CPU.Build.0 = Release|Any CPU |
|
30 | 36 |
EndGlobalSection |
31 | 37 |
GlobalSection(SolutionProperties) = preSolution |
32 | 38 |
HideSolutionNode = FALSE |
Backend/BackendTesting/AnotationTesting.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace BackendTesting |
8 | 8 |
{ |
9 |
internal class AnotationTesting
|
|
9 |
public class AnotationTesting
|
|
10 | 10 |
{ |
11 | 11 |
} |
12 | 12 |
} |
Backend/BackendTesting/BackendTesting.csproj | ||
---|---|---|
24 | 24 |
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" /> |
25 | 25 |
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" /> |
26 | 26 |
<PackageReference Include="coverlet.collector" Version="3.1.0" /> |
27 |
<PackageReference Include="Selenium.WebDriver" Version="4.1.0" /> |
|
28 |
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="100.0.4896.6000" /> |
|
29 |
<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.30.0.1" /> |
|
27 |
</ItemGroup> |
|
28 |
|
|
29 |
<ItemGroup> |
|
30 |
<ProjectReference Include="..\Core\Core.csproj" /> |
|
30 | 31 |
</ItemGroup> |
31 | 32 |
|
32 | 33 |
</Project> |
Backend/BackendTesting/Constants.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace BackendTesting |
8 | 8 |
{ |
9 |
internal class Constants
|
|
9 |
public class Constants
|
|
10 | 10 |
{ |
11 | 11 |
} |
12 | 12 |
} |
Backend/BackendTesting/DocumentManagementTesting.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace BackendTesting |
8 | 8 |
{ |
9 |
internal class DocumentManagementTesting
|
|
9 |
public class DocumentManagementTesting
|
|
10 | 10 |
{ |
11 | 11 |
} |
12 | 12 |
} |
Backend/BackendTesting/FiltersTesting.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace BackendTesting |
8 | 8 |
{ |
9 |
internal class FiltersTesting
|
|
9 |
public class FiltersTesting
|
|
10 | 10 |
{ |
11 | 11 |
} |
12 | 12 |
} |
Backend/BackendTesting/ImportExportTesting.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace BackendTesting |
8 | 8 |
{ |
9 |
internal class ImportExportTesting
|
|
9 |
public class ImportExportTesting
|
|
10 | 10 |
{ |
11 | 11 |
} |
12 | 12 |
} |
Backend/BackendTesting/LoginTesting.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace BackendTesting |
8 | 8 |
{ |
9 |
internal class LoginTesting
|
|
9 |
public class LoginTesting
|
|
10 | 10 |
{ |
11 | 11 |
} |
12 | 12 |
} |
Backend/BackendTesting/MainTestingClass.cs | ||
---|---|---|
1 |
using Microsoft.EntityFrameworkCore; |
|
2 |
using Microsoft.Extensions.Logging; |
|
3 |
using Microsoft.VisualStudio.TestTools.UnitTesting; |
|
4 |
|
|
5 |
using System; |
|
6 |
using System.Collections; |
|
7 |
using System.Collections.Generic; |
|
8 |
using System.Threading; |
|
9 |
|
|
10 |
namespace BackendTesting |
|
11 |
{ |
|
12 |
|
|
13 |
|
|
14 |
[TestClass] |
|
15 |
public class MainTestingClass |
|
16 |
{ |
|
17 |
//public TestContext context = new TestContext(); |
|
18 |
[TestMethod] |
|
19 |
public void runAll() |
|
20 |
{ |
|
21 |
|
|
22 |
|
|
23 |
} |
|
24 |
|
|
25 |
|
|
26 |
/* |
|
27 |
public IWebDriver fDriver = new FirefoxDriver(); |
|
28 |
public IWebDriver cDriver = new ChromeDriver(); |
|
29 |
[TestMethod] |
|
30 |
public void DummyTutorial() |
|
31 |
{ |
|
32 |
var webDriver = cDriver; //potrebuje "using selenium a chrome (firefox) |
|
33 |
//priprava promennych |
|
34 |
By googleSearchBar = By.Name("q"); |
|
35 |
By googleSearchButton = By.Name("btnK"); |
|
36 |
By searchName = By.XPath("//h2//span[text()='Elden Ring']"); |
|
37 |
By googleCoockieAggreementButton = By.Id("L2AGLb"); |
|
38 |
|
|
39 |
//prace s driverem |
|
40 |
webDriver.Manage().Window.Maximize(); |
|
41 |
webDriver.Navigate().GoToUrl("https://www.google.com/"); //zakladni stranka |
|
42 |
Thread.Sleep(500); |
|
43 |
|
|
44 |
webDriver.FindElement(googleCoockieAggreementButton).Click(); //odsouhlaseni coockies |
|
45 |
Thread.Sleep(500); |
|
46 |
|
|
47 |
webDriver.FindElement(googleSearchBar).SendKeys("Elden Ring"); //napsat Elden Ring do hledani |
|
48 |
Thread.Sleep(500); |
|
49 |
webDriver.FindElement(googleSearchButton).Click(); //kliknout na button pro poslani prikazu |
|
50 |
Thread.Sleep(500); |
|
51 |
|
|
52 |
var resultText = webDriver.FindElement(searchName); //najit pomoci xpath pozadovany element a ulozit si ho |
|
53 |
|
|
54 |
Assert.IsTrue(resultText.Text == "Elden Ring"); //samotny test pro otestovani stazene hodnoty |
|
55 |
|
|
56 |
|
|
57 |
webDriver.Quit(); //ukonceni webdriveru |
|
58 |
} |
|
59 |
*/ |
|
60 |
|
|
61 |
} |
|
62 |
} |
Backend/BackendTesting/Main_Testing_Class.cs | ||
---|---|---|
1 |
using Microsoft.VisualStudio.TestTools.UnitTesting; |
|
2 |
using OpenQA.Selenium; |
|
3 |
using OpenQA.Selenium.Chrome; |
|
4 |
using OpenQA.Selenium.Firefox; |
|
5 |
|
|
6 |
using System; |
|
7 |
using System.Collections; |
|
8 |
using System.Collections.Generic; |
|
9 |
using System.Threading; |
|
10 |
|
|
11 |
namespace BackendTesting |
|
12 |
{ |
|
13 |
[TestClass] |
|
14 |
public class Main_Testing_Class |
|
15 |
{ |
|
16 |
public IWebDriver fDriver = new FirefoxDriver(); |
|
17 |
public IWebDriver cDriver = new ChromeDriver(); |
|
18 |
|
|
19 |
|
|
20 |
[TestMethod] |
|
21 |
public void DummyTutorial() |
|
22 |
{ |
|
23 |
var webDriver = cDriver; //potrebuje "using selenium a chrome (firefox) |
|
24 |
//priprava promennych |
|
25 |
By googleSearchBar = By.Name("q"); |
|
26 |
By googleSearchButton = By.Name("btnK"); |
|
27 |
By searchName = By.XPath("//h2//span[text()='Elden Ring']"); |
|
28 |
By googleCoockieAggreementButton = By.Id("L2AGLb"); |
|
29 |
|
|
30 |
//prace s driverem |
|
31 |
webDriver.Manage().Window.Maximize(); |
|
32 |
webDriver.Navigate().GoToUrl("https://www.google.com/"); //zakladni stranka |
|
33 |
Thread.Sleep(500); |
|
34 |
|
|
35 |
webDriver.FindElement(googleCoockieAggreementButton).Click(); //odsouhlaseni coockies |
|
36 |
Thread.Sleep(500); |
|
37 |
|
|
38 |
webDriver.FindElement(googleSearchBar).SendKeys("Elden Ring"); //napsat Elden Ring do hledani |
|
39 |
Thread.Sleep(500); |
|
40 |
webDriver.FindElement(googleSearchButton).Click(); //kliknout na button pro poslani prikazu |
|
41 |
Thread.Sleep(500); |
|
42 |
|
|
43 |
var resultText = webDriver.FindElement(searchName); //najit pomoci xpath pozadovany element a ulozit si ho |
|
44 |
|
|
45 |
Assert.IsTrue(resultText.Text == "Elden Ring"); //samotny test pro otestovani stazene hodnoty |
|
46 |
|
|
47 |
|
|
48 |
webDriver.Quit(); //ukonceni webdriveru |
|
49 |
} |
|
50 |
|
|
51 |
|
|
52 |
} |
|
53 |
} |
Backend/BackendTesting/TagsManagementTesting.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace BackendTesting |
8 | 8 |
{ |
9 |
internal class TagsManagementTesting
|
|
9 |
public class TagsManagementTesting
|
|
10 | 10 |
{ |
11 | 11 |
} |
12 | 12 |
} |
Backend/BackendTesting/UserManagementTesting.cs | ||
---|---|---|
1 |
using System; |
|
1 |
using Microsoft.VisualStudio.TestTools.UnitTesting; |
|
2 |
using Models.Enums; |
|
3 |
using Core.Entities; |
|
4 |
using Serilog; |
|
5 |
|
|
6 |
using System; |
|
2 | 7 |
using System.Collections.Generic; |
3 | 8 |
using System.Linq; |
4 | 9 |
using System.Text; |
5 | 10 |
using System.Threading.Tasks; |
11 |
using Microsoft.EntityFrameworkCore; |
|
12 |
using AutoMapper; |
|
13 |
using Core.MapperProfiles; |
|
14 |
using Core.Contexts; |
|
15 |
using Microsoft.Extensions.Configuration; |
|
6 | 16 |
|
7 |
namespace BackendTesting
|
|
17 |
namespace Core.Services
|
|
8 | 18 |
{ |
9 |
internal class UserManagementTesting
|
|
19 |
public class UserContext : DatabaseContext
|
|
10 | 20 |
{ |
21 |
public UserContext(IConfiguration configuration) : base(configuration) { } |
|
22 |
|
|
23 |
//public static ILoggerFactory logger = LoggerFactory.Create(builder => { builder.AddConsole(); }); |
|
24 |
public ILogger logger = new LoggerConfiguration().WriteTo.Console().CreateLogger(); /* logger */ |
|
25 |
|
|
26 |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) |
|
27 |
{ |
|
28 |
base.OnConfiguring(optionsBuilder); |
|
29 |
optionsBuilder.UseSqlite("Data source=db.sqlite", b => b.MigrationsAssembly("RestAPI")); |
|
30 |
//optionsBuilder.(logger); |
|
31 |
} |
|
32 |
|
|
33 |
} |
|
34 |
[TestClass] |
|
35 |
public class UserManagementTesting //testing of Core/Services/UserService |
|
36 |
{ |
|
37 |
|
|
11 | 38 |
} |
12 | 39 |
} |
Backend/BackendTesting/Utils.cs | ||
---|---|---|
1 |
using System; |
|
1 |
using Microsoft.VisualStudio.TestTools.UnitTesting; |
|
2 |
using Models.Enums; |
|
3 |
using Core.Entities; |
|
4 |
using Serilog; |
|
5 |
|
|
6 |
using System; |
|
2 | 7 |
using System.Collections.Generic; |
3 | 8 |
using System.Linq; |
4 | 9 |
using System.Text; |
5 | 10 |
using System.Threading.Tasks; |
11 |
using Microsoft.EntityFrameworkCore; |
|
12 |
using AutoMapper; |
|
13 |
using Core.MapperProfiles; |
|
6 | 14 |
|
7 |
namespace BackendTesting
|
|
15 |
namespace Core.Services
|
|
8 | 16 |
{ |
9 |
internal class Utils |
|
17 |
public class Utils |
|
18 |
{ |
|
19 |
} |
|
20 |
|
|
21 |
public static class TestingMapper |
|
22 |
{ |
|
23 |
public static IMapper GetMapper() |
|
24 |
{ |
|
25 |
var mapperConfig = new MapperConfiguration(cfg => |
|
26 |
{ |
|
27 |
cfg.AddProfile<DocumentProfileEF>(); |
|
28 |
cfg.AddProfile<UserProfileEF>(); |
|
29 |
cfg.AddProfile<TagProfileEF>(); |
|
30 |
}); |
|
31 |
|
|
32 |
IMapper mapper = mapperConfig.CreateMapper(); |
|
33 |
return mapper; |
|
34 |
} |
|
35 |
} |
|
36 |
public static class TestingLogger |
|
10 | 37 |
{ |
38 |
public static ILogger GetLogger() |
|
39 |
{ |
|
40 |
return new LoggerConfiguration().WriteTo.Console().CreateLogger(); /* logger */ |
|
41 |
} |
|
11 | 42 |
} |
12 | 43 |
} |
Backend/Core/Contexts/DatabaseContext.cs | ||
---|---|---|
31 | 31 |
|
32 | 32 |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) |
33 | 33 |
{ |
34 |
optionsBuilder.UseNpgsql(_configuration["ConnectionString"], b => b.MigrationsAssembly("RestAPI")); |
|
34 |
//optionsBuilder.UseNpgsql(_configuration["ConnectionString"], b => b.MigrationsAssembly("RestAPI")); |
|
35 |
optionsBuilder.UseNpgsql("Host=localhost:5432;Database=dbo;Username=myuser;Password=password"); |
|
35 | 36 |
} |
36 | 37 |
} |
37 | 38 |
} |
README.md | ||
---|---|---|
9 | 9 |
CREATE DATABASE dbo; |
10 | 10 |
CREATE USER myuser WITH PASSWORD 'password'; |
11 | 11 |
GRANT ALL PRIVILEGES ON DATABASE dbo TO myuser; |
12 |
ALTER ROLE myuser WITH SUPERUSER; |
Také k dispozici: Unified diff
Fixed comments from code review, fixed DB access