Projekt

Obecné

Profil

Stáhnout (1.94 KB) Statistiky
| Větev: | Tag: | Revize:
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

    
18
namespace ServerApp.Predictor.Tests
19
{
20
    [TestClass()]
21
    public class PredictionControllerTests
22
    {
23
        [TestMethod()]
24
        public void PredictSingleTimeWeatherTest()
25
        {
26
            System.IO.Directory.CreateDirectory(@".\data");
27
            DataDownloader dd = new DataDownloader(@".\data\dd\", "http://openstore.zcu.cz/", "OD_ZCU_{type}_{month}_{year}_{format}.zip");
28
            PredictionController instance = new PredictionController(new JsonParser(dd, new CsvDataLoader()), new DataParser(dd));
29

    
30
            dd.DownloadData(DataType.JIS, DataFormat.CSV, new DataDownload.Date(1, 2019), new DataDownload.Date(12, 2020));
31
            dd.DownloadData(DataType.STROJE, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2020));
32
            dd.DownloadData(DataType.POCASI, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2020));
33
            instance.Train();
34

    
35
            Request request = new Request()
36
            {
37
                useEndDate = false,
38
                useWeather = false,
39
                start = new Connection.XMLProtocolHandler.Date()
40
                {
41
                    day = DateTime.Now.Day,
42
                    month = DateTime.Now.Month,
43
                    year = DateTime.Now.Year,
44
                    hour = 10
45
                }
46
            };
47
            Response actual = instance.Predict(request);
48
            CollectionAssert.AllItemsAreInstancesOfType(actual.predicitons, typeof(Prediction));
49
            Assert.AreEqual(1, actual.predicitons.Length);
50
        }
51
    }
52
}
    (1-1/1)