Revize c592262d
Přidáno uživatelem Eliška Mourycová před více než 3 roky(ů)
Server/ServerAppFunctionalTests/DownloaderTests/DataDownloaderTesting.cs | ||
---|---|---|
22 | 22 |
[TestMethod] |
23 | 23 |
public void DirectoryCreated() |
24 | 24 |
{ |
25 |
dd = new DataDownloader("./testDD", "http://openstore.zcu.cz/", "OD_ZCU_{type}_{month}_{year}_{format}.zip", "http://wttr.in/Plzen,czechia?format=j1"); |
|
26 | 25 |
bool rootDirExists = Directory.Exists(dd.RootDataDirectory); |
27 | 26 |
Assert.IsTrue(rootDirExists); |
28 | 27 |
} |
... | ... | |
30 | 29 |
[TestMethod] |
31 | 30 |
public void DataSubdirectoriesCreated() |
32 | 31 |
{ |
32 |
bool jisDirExists = Directory.Exists(dd.DataSubDirectories[DataType.JIS]); |
|
33 |
bool pcDirExists = Directory.Exists(dd.DataSubDirectories[DataType.STROJE]); |
|
34 |
bool weatherDirExists = Directory.Exists(dd.DataSubDirectories[DataType.POCASI]); |
|
35 |
// other sub dirs aren't that important |
|
33 | 36 |
|
37 |
bool allTrue = jisDirExists && pcDirExists && weatherDirExists; |
|
38 |
Assert.IsTrue(allTrue); |
|
34 | 39 |
} |
35 | 40 |
|
36 | 41 |
[TestMethod] |
37 | 42 |
public void DataDownload() |
38 | 43 |
{ |
44 |
// TODO split asserts |
|
39 | 45 |
|
46 |
// I know a file with this date is stored at the website: |
|
47 |
List<string> files = dd.DownloadData(DataType.JIS, DataFormat.CSV, new Date(10, 2019), new Date(10, 2019)); |
|
48 |
Assert.IsNotNull(files); |
|
49 |
|
|
50 |
// we expect 2, because the 00 file will be found as well |
|
51 |
Assert.AreEqual(2, files.Count); |
|
40 | 52 |
} |
41 | 53 |
|
42 | 54 |
[TestMethod] |
43 |
public void DataRetrieve() |
|
55 |
public void DataRetrieveSpecific()
|
|
44 | 56 |
{ |
57 |
// TODO split asserts |
|
58 |
|
|
59 |
List<string> files = dd.GetData(dd.DataSubDirectories[DataType.JIS], new Date(10, 2019), new Date(10, 2019)); |
|
60 |
string expectedName = "10-2019.CSV"; |
|
61 |
Assert.IsNotNull(files); |
|
62 |
Assert.AreEqual(1, files.Count); |
|
63 |
Assert.AreEqual(expectedName, Path.GetFileName(files[0])); |
|
64 |
} |
|
45 | 65 |
|
66 |
[TestMethod] |
|
67 |
public void DataRetrieveAll() |
|
68 |
{ |
|
69 |
List<string> files = dd.GetData(dd.DataSubDirectories[DataType.JIS], null, null); |
|
70 |
Assert.IsNotNull(files); |
|
71 |
Assert.AreEqual(2, files.Count); |
|
46 | 72 |
} |
47 | 73 |
|
48 | 74 |
[TestMethod] |
... | ... | |
50 | 76 |
{ |
51 | 77 |
|
52 | 78 |
} |
79 |
|
|
80 |
[TestMethod] |
|
81 |
public void WeatherPredictionDownload() |
|
82 |
{ |
|
83 |
string weatherJson = dd.DownloadWeatherPrediction(); |
|
84 |
Assert.IsNotNull(weatherJson); |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
//[AssemblyCleanup] |
|
89 |
//public static void AssemblyCleanup() |
|
90 |
//{ |
|
91 |
// try |
|
92 |
// { |
|
93 |
// Directory.Delete(dd.RootDataDirectory, true); |
|
94 |
// } |
|
95 |
// catch (DirectoryNotFoundException dnfe) |
|
96 |
// { |
|
97 |
|
|
98 |
// } |
|
99 |
//} |
|
53 | 100 |
} |
54 | 101 |
} |
Také k dispozici: Unified diff
Re #9051. Added tests for data downloading and retrieval.