commit 5e599715c824a856b3f52ca9b95e61b42b0e14a9
Author: schenkj <schenkj@students.zcu.cz>
Date:   Tue May 3 08:29:48 2022 +0200

    Prepared for tags testing
    
    tags testing preparations and removal of not used classes prepared before in testing skelet

diff --git a/Backend/BackendTesting/Constants.cs b/Backend/BackendTesting/Constants.cs
deleted file mode 100644
index 4f36e3c..0000000
--- a/Backend/BackendTesting/Constants.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BackendTesting
-{
-    public class Constants
-    {
-    }
-}
diff --git a/Backend/BackendTesting/FiltersTesting.cs b/Backend/BackendTesting/FiltersTesting.cs
deleted file mode 100644
index d3691fe..0000000
--- a/Backend/BackendTesting/FiltersTesting.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BackendTesting
-{
-    public class FiltersTesting
-    {
-    }
-}
diff --git a/Backend/BackendTesting/ImportExportTesting.cs b/Backend/BackendTesting/ImportExportTesting.cs
deleted file mode 100644
index 8d1a872..0000000
--- a/Backend/BackendTesting/ImportExportTesting.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BackendTesting
-{
-    public class ImportExportTesting
-    {
-    }
-}
diff --git a/Backend/BackendTesting/LoginTesting.cs b/Backend/BackendTesting/LoginTesting.cs
deleted file mode 100644
index 4c853c6..0000000
--- a/Backend/BackendTesting/LoginTesting.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BackendTesting
-{
-    public class LoginTesting
-    {
-    }
-}
diff --git a/Backend/BackendTesting/MainTestingClass.cs b/Backend/BackendTesting/MainTestingClass.cs
deleted file mode 100644
index 979c6cc..0000000
--- a/Backend/BackendTesting/MainTestingClass.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Logging;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Threading;
-
-namespace BackendTesting
-{
-
-
-    [TestClass]
-    public class MainTestingClass
-    {
-        //public TestContext context = new TestContext();
-        [TestMethod]
-        public void runAll()
-        {
-            
-
-        } 
-
-
-        /*
-        public IWebDriver fDriver = new FirefoxDriver();
-        public IWebDriver cDriver = new ChromeDriver();
-        [TestMethod]
-        public void DummyTutorial()
-        {
-            var webDriver = cDriver; //potrebuje "using selenium a chrome (firefox)
-            //priprava promennych
-            By googleSearchBar = By.Name("q");
-            By googleSearchButton = By.Name("btnK");
-            By searchName = By.XPath("//h2//span[text()='Elden Ring']");
-            By googleCoockieAggreementButton = By.Id("L2AGLb");
-
-            //prace s driverem
-            webDriver.Manage().Window.Maximize();
-            webDriver.Navigate().GoToUrl("https://www.google.com/");    //zakladni stranka
-            Thread.Sleep(500);
-
-            webDriver.FindElement(googleCoockieAggreementButton).Click();           //odsouhlaseni coockies
-            Thread.Sleep(500);
-
-            webDriver.FindElement(googleSearchBar).SendKeys("Elden Ring");          //napsat Elden Ring do hledani
-            Thread.Sleep(500);
-            webDriver.FindElement(googleSearchButton).Click();                      //kliknout na button pro poslani prikazu
-            Thread.Sleep(500);
-
-            var resultText = webDriver.FindElement(searchName);                     //najit pomoci xpath pozadovany element a ulozit si ho
-
-            Assert.IsTrue(resultText.Text == "Elden Ring"); //samotny test pro otestovani stazene hodnoty
-
-
-            webDriver.Quit();                                                          //ukonceni webdriveru
-        }
-        */
-
-    }
-}
diff --git a/Backend/BackendTesting/TagsManagementTesting.cs b/Backend/BackendTesting/TagsManagementTesting.cs
index 2e3abb0..4f68384 100644
--- a/Backend/BackendTesting/TagsManagementTesting.cs
+++ b/Backend/BackendTesting/TagsManagementTesting.cs
@@ -1,12 +1,151 @@
-﻿using System;
+﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Models.Enums;
+using Core.Entities;
+using Serilog;
+
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore;
+using AutoMapper;
+using Core.MapperProfiles;
+using Core.Contexts;
+using Microsoft.Extensions.Configuration;
+using Models.Documents;
+using Core.Services;
 
 namespace BackendTesting
 {
+    [TestClass]
     public class TagsManagementTesting
     {
+        private static readonly IConfiguration configuration = new ConfigurationBuilder().Build();
+        public DatabaseContext ctx;
+        //public Core.Services.DocumentService.IDocumentService DS;
+        //public Core.Services.IUserService US;
+        public Core.Services.TagService.ITagService TS;
+        //public DocumentAddRequest docList;
+        public User user;
+
+        //constructor for testing tags and anotations
+        public TagsManagementTesting()
+        {
+            //creating new database
+            this.ctx = new DatabaseContext(configuration);
+            //this.DS = new Core.Services.DocumentService.DocumentServiceEF(this.ctx, TestingLogger.GetLogger(), TestingMapper.GetMapper());
+            //this.US = new UserServiceEF(this.ctx, TestingLogger.GetLogger(), TestingMapper.GetMapper());
+            this.TS = new Core.Services.TagService.TagServiceEF(ctx, TestingLogger.GetLogger(), TestingMapper.GetMapper());
+
+            AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
+
+            //ensure the database is fresh without unwanted users from previous testings
+            ctx.Database.EnsureDeleted();
+            ctx.Database.EnsureCreated();
+
+            //user = new() { Id = Guid.NewGuid(), Name = "aa", Surname = "aa", Password = "aa", Role = ERole.ADMINISTRATOR, Username = "aa" };
+            //ctx.Users.Add(user);
+            //ctx.SaveChanges();
+
+            //docList = MakeRequest();
+            //FillUsers();
+            //ctx.SaveChanges();
+        }
+
+        [TestMethod]
+        public void GetTagTree_Testing()
+        {
+            try
+            {
+                var tagTree = TS.GetTagTree();
+                
+                //TODO - pridavat kategorie, tagy a podtagy
+                //kontrolovat zda jsou tam vsechny a spravne
+                //pripadne je zkusit odebirat (az budou na backendu doresene)
+
+
+
+            }
+            catch(Exception ex)
+            {
+                Assert.Fail("GetTagTree() failed on exception: " + ex);
+            }
+            
+
+
+        }
+
+
+
+
+
+
+
+
+        /*
+        private void FillUsers()
+        {
+            var userList = new List<User>();
+            userList.Add(new User() { Username = "aaa", Name = "aaa", Surname = "aaa", Password = "aaa", Role = Models.Enums.ERole.ANNOTATOR });
+            userList.Add(new User() { Username = "bbb", Name = "bbb", Surname = "bbb", Password = "bbb", Role = Models.Enums.ERole.ANNOTATOR });
+            userList.Add(new User() { Username = "ccc", Name = "ccc", Surname = "ccc", Password = "ccc", Role = Models.Enums.ERole.ADMINISTRATOR });
+            userList.Add(new User() { Username = "ddd", Name = "ddd", Surname = "ddd", Password = "ddd", Role = Models.Enums.ERole.ANNOTATOR });
+            userList.Add(new User() { Username = "eee", Name = "eee", Surname = "eee", Password = "eee", Role = Models.Enums.ERole.ANNOTATOR });
+            userList.Add(new User() { Username = "fff", Name = "fff", Surname = "fff", Password = "fff", Role = Models.Enums.ERole.ANNOTATOR });
+            userList.Add(new User() { Username = "ggg", Name = "ggg", Surname = "ggg", Password = "ggg", Role = Models.Enums.ERole.ANNOTATOR });
+            userList.Add(new User() { Username = "hhh", Name = "hhh", Surname = "hhh", Password = "hhh", Role = Models.Enums.ERole.ADMINISTRATOR });
+            userList.Add(new User() { Username = "iii", Name = "iii", Surname = "iii", Password = "iii", Role = Models.Enums.ERole.ADMINISTRATOR });
+            userList.Add(new User() { Username = "jjj", Name = "jjj", Surname = "jjj", Password = "jjj", Role = Models.Enums.ERole.ADMINISTRATOR });
+
+            //filling up the database
+            foreach (var user in userList)
+            {
+                US.CreateUser(user.Username, user.Name, user.Surname, user.Password, user.Role);
+            }
+            ctx.SaveChanges();
+        }
+
+        private DocumentAddRequest MakeRequest()
+        {
+            docList = new DocumentAddRequest() { Documents = new() };
+            var dc = new DocumentContent();
+            string content = "aaa <html> bbb";
+            content = Convert.ToBase64String(Encoding.UTF8.GetBytes(content));
+            dc.Content = content;
+            var dt = new DateTime(2022, 4, 11);
+            DocumentAddInfo info = new DocumentAddInfo();
+            info.Name = "a";
+            info.Content = content;
+            info.Format = EAddDocumentFormat.TEXTFILE;
+            docList.Documents.Add(info);
+
+            content = "aaa <html> <xss> \n xdd<abc> nonvalid xml<tag>abc <tag2?> bbb";
+            dc.Content = content;
+            dt = new DateTime(2022, 4, 12);
+            docList.Documents.Add(new DocumentAddInfo() { Name = "b", Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(content)), Format = EAddDocumentFormat.TEXTFILE });
+
+            content = "aaa <html> bbb aaa <html> <xss> \n xdd<abc> nonvalid xml<tag>abc <tag2?>" +
+                " bbb aaa <html> <xss> \n xdd<abc> nonvalid xml<tag>abc <tag2?> bbb aaa <html> <xss> \n xdd<abc>" +
+                " nonvalid xml<tag>abc <tag2?> bbb aaa <html> <xss> \n xdd<abc> nonvalid xml<tag>abc <tag2?> bbb aaa <html>" +
+                " <xss> \n xdd<abc> nonvalid xml<tag>abc <tag2?> bbb aaa <html> <xss> \n xdd<abc> nonvalid xml<tag>abc <tag2?>" +
+                " bbb aaa <html> <xss> \n xdd<abc> nonvalid xml<tag>abc <tag2?> bbb aaa <html> <xss> \n xdd<abc> nonvalid xml<tag>abc <tag2?> bbb ";
+            dc.Content = content;
+            dt = new DateTime(2022, 4, 13);
+            docList.Documents.Add(new DocumentAddInfo() { Name = "c", Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(content)), Format = EAddDocumentFormat.TEXTFILE });
+
+            content = "aaa";
+            dc.Content = content;
+            dt = new DateTime(2022, 4, 14);
+            docList.Documents.Add(new DocumentAddInfo() { Name = "d", Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(content)), Format = EAddDocumentFormat.TEXTFILE });
+
+            content = "aaa <html> edfgckvhbjno§mpoizuzcjtjczkutvlzibůuoni§piuoůbzivlutkczjxzcktuvlziůuoi§ouůizvlutckzxjzckguvl h.gjcutfgýíáéphuoůizltukridýžáflizv bbb";
+            dc.Content = content;
+            dt = new DateTime(2022, 4, 15);
+            docList.Documents.Add(new DocumentAddInfo() { Name = "e", Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(content)), Format = EAddDocumentFormat.TEXTFILE });
+
+            return docList;
+        }
+        */
     }
 }
