commit 99e5517e5267fac0777a9db53305ff6075c7cf1a
Author: A-Konig <alex-nebulae@seznam.cz>
Date:   Sun May 16 11:43:53 2021 +0200

    re #8842 Start testing

diff --git a/Server/ServerApp.sln b/Server/ServerApp.sln
index 40c86ce..89c9211 100644
--- a/Server/ServerApp.sln
+++ b/Server/ServerApp.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.31105.61
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerApp", "ServerApp\ServerApp.csproj", "{18FCFB20-B860-4147-8E7C-8A0DD84C55D4}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProject", "TestProject\TestProject.csproj", "{8A09DB8E-64B1-4D55-991E-7F7B21996B45}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,14 @@ Global
 		{18FCFB20-B860-4147-8E7C-8A0DD84C55D4}.Release|Any CPU.Build.0 = Release|Any CPU
 		{18FCFB20-B860-4147-8E7C-8A0DD84C55D4}.Release|x64.ActiveCfg = Release|x64
 		{18FCFB20-B860-4147-8E7C-8A0DD84C55D4}.Release|x64.Build.0 = Release|x64
+		{8A09DB8E-64B1-4D55-991E-7F7B21996B45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{8A09DB8E-64B1-4D55-991E-7F7B21996B45}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{8A09DB8E-64B1-4D55-991E-7F7B21996B45}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{8A09DB8E-64B1-4D55-991E-7F7B21996B45}.Debug|x64.Build.0 = Debug|Any CPU
+		{8A09DB8E-64B1-4D55-991E-7F7B21996B45}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{8A09DB8E-64B1-4D55-991E-7F7B21996B45}.Release|Any CPU.Build.0 = Release|Any CPU
+		{8A09DB8E-64B1-4D55-991E-7F7B21996B45}.Release|x64.ActiveCfg = Release|Any CPU
+		{8A09DB8E-64B1-4D55-991E-7F7B21996B45}.Release|x64.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs b/Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs
index 6d17e4f..d3321a9 100644
--- a/Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs
+++ b/Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs
@@ -11,7 +11,7 @@ namespace ServerApp.Parser.OutputInfo
     /// - shortest possible interval is 1h
     /// </summary>
     /// <author>A. Konig</author>
-    class ActivityInfo
+    public class ActivityInfo
     {
         /// <summary> Building </summary>
         public string building;
diff --git a/Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs b/Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs
index 52d70cd..8ba044b 100644
--- a/Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs
+++ b/Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs
@@ -11,7 +11,7 @@ namespace ServerApp.Parser.OutputInfo
     /// - shortest possible interval is 1h
     /// </summary>
     /// <author>A. Konig</author>
-    class WeatherInfo
+    public class WeatherInfo
     {
         /// <summary> Temperature in °C </summary>
         public double temp;
diff --git a/Server/ServerApp/Parser/Parsers/DataParser.cs b/Server/ServerApp/Parser/Parsers/DataParser.cs
index 5313953..573b900 100644
--- a/Server/ServerApp/Parser/Parsers/DataParser.cs
+++ b/Server/ServerApp/Parser/Parsers/DataParser.cs
@@ -17,7 +17,7 @@ namespace ServerApp.Parser.Parsers
     /// Data parsed from 7am (included) to 18pm (included)
     /// </summary>
     /// <author>A. Konig</author>
-    class DataParser : IDataParser
+    public class DataParser : IDataParser
     {
         /// <summary> Data downloader </summary>
         DataDownloader downloader;
@@ -29,13 +29,6 @@ namespace ServerApp.Parser.Parsers
         /// <summary> Login data parser </summary>
         LogInParser loginParser;
 
-        /// <summary> WeatherInfo </summary>
-        List<WeatherInfo> weatherList;
-        public new List<WeatherInfo> WeatherList { get => weatherList; }
-        /// <summary> ActivityInfo repersenting overall activity </summary>
-        List<ActivityInfo> attendanceList;
-        public new List<ActivityInfo> AttendanceList { get => attendanceList; }
-
         /// <summary> ActivityInfo representing jis activity </summary>
         List<ActivityInfo> jisList;
         /// <summary> ActivityInfo representing login activity</summary>
@@ -89,7 +82,7 @@ namespace ServerApp.Parser.Parsers
             var jisFiles = downloader.GetData(pathJis, start, end);
             var loginFiles = downloader.GetData(pathLogIn, start, end);
 
-            weatherList = weatherParser.ParseWeatherData(weatherFiles, startTime, endTime, wholeDay, interval);
+            WeatherList = weatherParser.ParseWeatherData(weatherFiles, startTime, endTime, wholeDay, interval);
             jisList = jisParser.ParseJisData(jisFiles, startTime, endTime, wholeDay, interval);
             loginList = loginParser.ParseLogInData(loginFiles, startTime, endTime, wholeDay, interval);
 
@@ -102,24 +95,35 @@ namespace ServerApp.Parser.Parsers
 
             //WriteToConsole(AddListToOne(jisList));
 
-            MergeAttendance();
+            AttendanceList = MergeAttendance(jisList, loginList);
 
             //Console.WriteLine("MERGED IN ONE LIST");
             //WriteToConsole(attendanceList);
 
-            if (weatherList.Count == 0 || attendanceList.Count == 0)
+            if (WeatherList.Count == 0 || AttendanceList.Count == 0)
                 return false;
 
             return true;
         }
 
+
         /// <summary>
-        /// Merges ActivityInfo lists with jis and login activity into one
+        /// Merges two lists into one
         /// Adds information from the same time period together, doesn't change the rest
         /// </summary>
-        private void MergeAttendance()
+        /// <param name="jisList">List to merge</param>
+        /// <param name="loginList">List to merge</param>
+        /// <returns>Merged list</returns>
+        private List<ActivityInfo> MergeAttendance(List<ActivityInfo> jisList, List<ActivityInfo> loginList)
         {
-            attendanceList = new List<ActivityInfo>();
+            List<ActivityInfo> res = new List<ActivityInfo>();
+
+            if (jisList == null && loginList == null)
+                return res;
+            else if (jisList == null)
+                return loginList;
+            else if (loginList == null)
+                return jisList;
 
             int indexJis = 0, indexLogin = 0;
             while (true)
@@ -139,40 +143,41 @@ namespace ServerApp.Parser.Parsers
                     if (jisTag == loginTag)
                     {
                         jis.amount += login.amount;
-                        attendanceList.Add(jis);
+                        res.Add(jis);
                         indexJis++; indexLogin++;
                     }
 
-                    if (jisTag < loginTag)
+                    else if (jisTag < loginTag)
                     {
                         indexJis++;
-                        attendanceList.Add(jis);
+                        res.Add(jis);
                     }
 
-                    if (jisTag > loginTag)
+                    else if (jisTag > loginTag)
                     {
                         indexLogin++;
-                        attendanceList.Add(login);
+                        res.Add(login);
                     }
 
                 }
 
                 // if jis time is smaller -> add jis and move
-                if (jis.startTime < login.startTime)
+                else if (jis.startTime < login.startTime)
                 {
                     indexJis++;
-                    attendanceList.Add(jis);
+                    res.Add(jis);
                 }
 
                 // if login time is smaller -> add login and move
-                if (login.startTime < jis.startTime)
+                else if (login.startTime < jis.startTime)
                 {
                     indexLogin++;
-                    attendanceList.Add(login);
+                    res.Add(login);
                 }
 
             }
 
+            return res;
         }
 
         /// <summary>
diff --git a/Server/ServerApp/Parser/Parsers/IDataParser.cs b/Server/ServerApp/Parser/Parsers/IDataParser.cs
index a4d7fb8..ae67a00 100644
--- a/Server/ServerApp/Parser/Parsers/IDataParser.cs
+++ b/Server/ServerApp/Parser/Parsers/IDataParser.cs
@@ -12,14 +12,14 @@ namespace ServerApp.Parser.Parsers
     /// Abstract class that every DataParser should inherit from
     /// </summary>
     /// <author>A. Konig</author>
-    abstract class IDataParser
+    public abstract class IDataParser
     {
         /// <summary> WeatherInfo </summary>
         List<WeatherInfo> weatherList;
-        public List<WeatherInfo> WeatherList { get => weatherList; }
+        public List<WeatherInfo> WeatherList { get => weatherList; internal set => weatherList = value; }
         /// <summary> ActivityInfo repersenting overall activity </summary>
         List<ActivityInfo> attendanceList;
-        public List<ActivityInfo> AttendanceList { get => attendanceList; }
+        public List<ActivityInfo> AttendanceList { get => attendanceList; internal set => attendanceList = value; }
 
         /// <summary>
         /// Parse data
diff --git a/Server/ServerApp/Program.cs b/Server/ServerApp/Program.cs
index 745b356..0331392 100644
--- a/Server/ServerApp/Program.cs
+++ b/Server/ServerApp/Program.cs
@@ -83,11 +83,12 @@ namespace ServerApp
 			jsonP.ParsePrediction();
 
 			// TODO nastavit čas
-			DataParser p = new DataParser(dd);
-			DateTime startT = new DateTime(2019, 10, 5);
-			DateTime endT = new DateTime(2020, 6, 30);
+			IDataParser p = new DataParser(dd);
+			DateTime startT = new DateTime(2018, 6, 5);
+			DateTime endT = new DateTime(2019, 10, 30);
 			p.Parse(startT, endT, wholeDay: false, interval: 3);
 
+			Console.WriteLine(p.WeatherList.Count);
 
 			// test - connection:
 			//ConnectionListener cl = new ConnectionListener(int.Parse(args[0])/*8000*//*int.Parse(config.Port)*/);
diff --git a/Server/TestProject/Properties/AssemblyInfo.cs b/Server/TestProject/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..16e7cf6
--- /dev/null
+++ b/Server/TestProject/Properties/AssemblyInfo.cs
@@ -0,0 +1,20 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("TestProject")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TestProject")]
+[assembly: AssemblyCopyright("Copyright ©  2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("8a09db8e-64b1-4d55-991e-7f7b21996b45")]
+
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Server/TestProject/TestProject.csproj b/Server/TestProject/TestProject.csproj
new file mode 100644
index 0000000..f3a73e8
--- /dev/null
+++ b/Server/TestProject/TestProject.csproj
@@ -0,0 +1,89 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{8A09DB8E-64B1-4D55-991E-7F7B21996B45}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>TestProject</RootNamespace>
+    <AssemblyName>TestProject</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+    <IsCodedUITest>False</IsCodedUITest>
+    <TestProjectType>UnitTest</TestProjectType>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x64</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+      <HintPath>..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="Moq, Version=4.16.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
+      <HintPath>..\packages\Moq.4.16.1\lib\net45\Moq.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="TestingParser.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="app.config" />
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\ServerApp\ServerApp.csproj">
+      <Project>{18fcfb20-b860-4147-8e7c-8a0dd84c55d4}</Project>
+      <Name>ServerApp</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
+    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
+  </Target>
+  <Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
+</Project>
\ No newline at end of file
diff --git a/Server/TestProject/TestingParser.cs b/Server/TestProject/TestingParser.cs
new file mode 100644
index 0000000..bf0cb90
--- /dev/null
+++ b/Server/TestProject/TestingParser.cs
@@ -0,0 +1,66 @@
+﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using ServerApp.Parser.Parsers;
+using System.Collections.Generic;
+using ServerApp.Parser.OutputInfo;
+
+namespace TestProject
+{
+    [TestClass]
+    public class TestingParser
+    {
+        [TestMethod]
+        public void AbstactClassTest()
+        {
+            IDataParser p = new DataParser(null);
+            List<ActivityInfo> aa = p.AttendanceList;
+            List<WeatherInfo> wa = p.WeatherList;
+
+            DataParser pp = (DataParser)p;
+            List<ActivityInfo> ap = pp.AttendanceList;
+            List<WeatherInfo> wp = pp.WeatherList;
+
+            Assert.AreEqual(aa, ap);
+            Assert.AreEqual(wa, wp);
+        }
+
+        [TestMethod]
+        public void MergeListsNull()
+        {
+            DataParser target = new DataParser(null);
+            PrivateObject obj = new PrivateObject(target);
+
+            List<ActivityInfo> jis = null;
+            List<ActivityInfo> pc = null;
+
+            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
+            Assert.AreEqual(0, retVal.Count);
+        }
+
+        [TestMethod]
+        public void MergeListsJisNull()
+        {
+            DataParser target = new DataParser(null);
+            PrivateObject obj = new PrivateObject(target);
+
+            List<ActivityInfo> jis = null;
+            List<ActivityInfo> pc = new List<ActivityInfo>();
+
+            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
+            Assert.AreEqual(pc, retVal);
+        }
+
+        [TestMethod]
+        public void MergeListsPcNull()
+        {
+            DataParser target = new DataParser(null);
+            PrivateObject obj = new PrivateObject(target);
+
+            List<ActivityInfo> jis = new List<ActivityInfo>();
+            List<ActivityInfo> pc = null;
+
+            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
+            Assert.AreEqual(jis, retVal);
+        }
+    }
+}
diff --git a/Server/TestProject/app.config b/Server/TestProject/app.config
new file mode 100644
index 0000000..58b89cf
--- /dev/null
+++ b/Server/TestProject/app.config
@@ -0,0 +1,15 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+</configuration>
\ No newline at end of file
diff --git a/Server/TestProject/packages.config b/Server/TestProject/packages.config
new file mode 100644
index 0000000..2bf9538
--- /dev/null
+++ b/Server/TestProject/packages.config
@@ -0,0 +1,9 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Castle.Core" version="4.4.0" targetFramework="net472" />
+  <package id="Moq" version="4.16.1" targetFramework="net472" />
+  <package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net472" />
+  <package id="MSTest.TestFramework" version="2.1.2" targetFramework="net472" />
+  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
+  <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
+</packages>
\ No newline at end of file
