1
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2
|
using ServerApp.Predictor;
|
3
|
//
|
4
|
// Author: Roman Kalivoda
|
5
|
//
|
6
|
|
7
|
using System;
|
8
|
using System.Collections.Generic;
|
9
|
using System.Linq;
|
10
|
using System.Text;
|
11
|
using System.Threading.Tasks;
|
12
|
using ServerApp.WeatherPredictionParser;
|
13
|
using ServerApp.Parser.Parsers;
|
14
|
using ServerApp.Parser.InputData;
|
15
|
using ServerApp.Connection.XMLProtocolHandler;
|
16
|
using ServerApp.DataDownload;
|
17
|
using log4net.Config;
|
18
|
|
19
|
namespace ServerApp.Predictor.Tests
|
20
|
{
|
21
|
[TestClass()]
|
22
|
public class PredictionControllerTests
|
23
|
{
|
24
|
[AssemblyInitialize()]
|
25
|
public static void ClassInit(TestContext context)
|
26
|
{
|
27
|
// setup logging service
|
28
|
XmlConfigurator.Configure();
|
29
|
}
|
30
|
|
31
|
[TestMethod()]
|
32
|
public void PredictSingleTimeWeatherTest()
|
33
|
{
|
34
|
System.IO.Directory.CreateDirectory(@".\data");
|
35
|
DataDownloader dd = new DataDownloader(@".\data\dd\", "http://openstore.zcu.cz/", "OD_ZCU_{type}_{month}_{year}_{format}.zip", "http://wttr.in/Plzen,czechia?format=j1");
|
36
|
PredictionController instance = new PredictionController(new JsonParser(dd, new CsvDataLoader()), new DataParser(dd));
|
37
|
|
38
|
dd.DownloadData(DataType.JIS, DataFormat.CSV, new DataDownload.Date(1, 2019), new DataDownload.Date(12, 2020));
|
39
|
dd.DownloadData(DataType.STROJE, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2020));
|
40
|
dd.DownloadData(DataType.POCASI, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2020));
|
41
|
instance.Train();
|
42
|
|
43
|
Request request = new Request()
|
44
|
{
|
45
|
useEndDate = false,
|
46
|
useWeather = false,
|
47
|
start = new Connection.XMLProtocolHandler.Date()
|
48
|
{
|
49
|
day = DateTime.Now.Day,
|
50
|
month = DateTime.Now.Month,
|
51
|
year = DateTime.Now.Year,
|
52
|
hour = 10
|
53
|
}
|
54
|
};
|
55
|
Response actual = instance.Predict(request);
|
56
|
CollectionAssert.AllItemsAreInstancesOfType(actual.predicitons, typeof(Prediction));
|
57
|
Assert.AreEqual(1, actual.predicitons.Length);
|
58
|
}
|
59
|
}
|
60
|
}
|