Revize 4d957345
Přidáno uživatelem Eliška Mourycová před téměř 4 roky(ů)
Server/ServerAppFunctionalTests/AdminCommandsTests/AdminDataCommandsTesting.cs | ||
---|---|---|
7 | 7 |
using System.Text; |
8 | 8 |
using System.Threading.Tasks; |
9 | 9 |
using ServerApp.DataDownload; |
10 |
using Moq; |
|
10 | 11 |
|
11 | 12 |
namespace ServerAppFunctionalTests.AdminCommandsTests |
12 | 13 |
{ |
13 | 14 |
[TestClass] |
14 | 15 |
public class AdminDataCommandsTesting |
15 | 16 |
{ |
16 |
static CommandsAcceptor ca; |
|
17 | 17 |
|
18 |
[ClassInitialize]
|
|
19 |
public static void SetUpClass(TestContext context)
|
|
18 |
[TestMethod]
|
|
19 |
public void CommandParsingSimple()
|
|
20 | 20 |
{ |
21 |
DataDownloader dd = new DataDownloader("./testDD", "http://openstore.zcu.cz/", "OD_ZCU_{type}_{month}_{year}_{format}.zip", "http://wttr.in/Plzen,czechia?format=j1"); |
|
22 |
ca = new CommandsAcceptor(dd, null); |
|
23 |
|
|
21 |
CommandsAcceptor target = new CommandsAcceptor(null, null); |
|
22 |
PrivateObject obj = new PrivateObject(target); |
|
23 |
Command c = (Command)obj.Invoke("ParseString", "command"); |
|
24 |
|
|
25 |
Assert.IsNotNull(c); |
|
26 |
Assert.AreEqual("command", c.MainCommand); |
|
27 |
|
|
28 |
|
|
24 | 29 |
} |
25 | 30 |
|
31 |
|
|
26 | 32 |
[TestMethod] |
27 |
public void Test()
|
|
33 |
public void CommandParsingFlags()
|
|
28 | 34 |
{ |
29 |
StringReader stringReader = new StringReader("ahoj"); |
|
30 |
Console.SetIn(stringReader); |
|
31 |
ca.AcceptCommand(); |
|
35 |
CommandsAcceptor target = new CommandsAcceptor(null, null); |
|
36 |
PrivateObject obj = new PrivateObject(target); |
|
37 |
Command c = (Command)obj.Invoke("ParseString", " command -flag1 data1 data2 -flag2 data3 "); |
|
38 |
|
|
39 |
Assert.IsNotNull(c); |
|
40 |
Assert.AreEqual("command", c.MainCommand); |
|
41 |
Assert.AreEqual("command -flag1 data1 data2 -flag2 data3", c.WholeCommand); |
|
42 |
Assert.AreEqual(2, c.FlagsAndData.Count); |
|
43 |
Assert.AreEqual(2, c.FlagsAndData["flag1"].Count); |
|
44 |
Assert.AreEqual("data1", c.FlagsAndData["flag1"][0]); |
|
45 |
Assert.AreEqual("data2", c.FlagsAndData["flag1"][1]); |
|
46 |
Assert.AreEqual(1, c.FlagsAndData["flag2"].Count); |
|
47 |
Assert.AreEqual("data3", c.FlagsAndData["flag2"][0]); |
|
32 | 48 |
|
33 | 49 |
} |
34 | 50 |
|
Také k dispozici: Unified diff
Re #9050. Added tests for admin commands parsing.