Revize de139774
Přidáno uživatelem Alex Konig před více než 3 roky(ů)
Server/ServerAppFunctionalTests/ParserTests/JsonParserTesting.cs | ||
---|---|---|
429 | 429 |
#endregion |
430 | 430 |
|
431 | 431 |
#region GetPredictionForTime |
432 |
|
|
433 |
[TestMethod] |
|
434 |
public void GetPredictionForTimeOne() |
|
435 |
{ |
|
436 |
string data = ""; |
|
437 |
|
|
438 |
Mock<IDataDownloader> dl = new Mock<IDataDownloader>(); |
|
439 |
dl.Setup(m => m.DownloadWeatherPrediction()).Returns(data); |
|
440 |
|
|
441 |
Mock<IDataLoader> l = new Mock<IDataLoader>(); |
|
442 |
|
|
443 |
JsonParser target = new JsonParser(dl.Object, l.Object); |
|
444 |
|
|
445 |
List<WeatherInfo> pred = new List<WeatherInfo>(); |
|
446 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 1, 0, 0, 0), 8, 1, 2, 60_000, 3)); |
|
447 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 1, 3, 0, 0), 8, 1, 2, 60_000, 6)); |
|
448 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 1, 12, 0, 0), 8, 1, 2, 60_000, 6)); |
|
449 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 1, 18, 0, 0), 8, 1, 2, 60_000, 12)); |
|
450 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 2, 6, 0, 0), 8, 1, 2, 60_000, 3)); |
|
451 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 2, 9, 0, 0), 8, 1, 2, 60_000, 15)); |
|
452 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 3, 0, 0, 0), 8, 1, 2, 60_000, 3)); |
|
453 |
|
|
454 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 3, 3, 0, 0), 8, 1, 2, 60_000, 3)); |
|
455 |
|
|
456 |
target.Predictions = pred; |
|
457 |
|
|
458 |
List<WeatherInfo> retVal = target.GetPredictionForTime(new DateTime(2000, 1, 1, 3, 0, 0), new DateTime(2000, 1, 1, 3, 0, 0)); |
|
459 |
|
|
460 |
Assert.AreEqual(1, retVal.Count); |
|
461 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 3, 0, 0), 8, 1, 2, 60_000, 6), retVal[0]); |
|
462 |
} |
|
463 |
|
|
432 | 464 |
[TestMethod] |
433 | 465 |
public void GetPredictionForTimeFilter() |
434 | 466 |
{ |
... | ... | |
466 | 498 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 3, 0, 0, 0), 8, 1, 2, 60_000, 3), retVal[5]); |
467 | 499 |
} |
468 | 500 |
|
501 |
[TestMethod] |
|
502 |
public void GetPredictionForTimeFilterII() |
|
503 |
{ |
|
504 |
string data = ""; |
|
505 |
|
|
506 |
Mock<IDataDownloader> dl = new Mock<IDataDownloader>(); |
|
507 |
dl.Setup(m => m.DownloadWeatherPrediction()).Returns(data); |
|
508 |
|
|
509 |
Mock<IDataLoader> l = new Mock<IDataLoader>(); |
|
510 |
|
|
511 |
JsonParser target = new JsonParser(dl.Object, l.Object); |
|
512 |
|
|
513 |
List<WeatherInfo> pred = new List<WeatherInfo>(); |
|
514 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 1, 0, 0, 0), 8, 1, 2, 60_000, 3)); |
|
515 |
|
|
516 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 1, 3, 0, 0), 8, 1, 2, 60_000, 6)); |
|
517 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 1, 12, 0, 0), 8, 1, 2, 60_000, 6)); |
|
518 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 1, 18, 0, 0), 8, 1, 2, 60_000, 12)); |
|
519 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 2, 6, 0, 0), 8, 1, 2, 60_000, 3)); |
|
520 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 2, 9, 0, 0), 8, 1, 2, 60_000, 15)); |
|
521 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 3, 0, 0, 0), 8, 1, 2, 60_000, 3)); |
|
522 |
|
|
523 |
pred.Add(new WeatherInfo(new DateTime(2000, 1, 3, 3, 0, 0), 8, 1, 2, 60_000, 3)); |
|
524 |
|
|
525 |
target.Predictions = pred; |
|
526 |
|
|
527 |
List<WeatherInfo> retVal = target.GetPredictionForTime(new DateTime(2000, 1, 1, 6, 0, 0), new DateTime(2000, 1, 1, 18, 0, 0)); |
|
528 |
|
|
529 |
Assert.AreEqual(3, retVal.Count); |
|
530 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 3, 0, 0), 8, 1, 2, 60_000, 6), retVal[0]); |
|
531 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 12, 0, 0), 8, 1, 2, 60_000, 6), retVal[1]); |
|
532 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 18, 0, 0), 8, 1, 2, 60_000, 12), retVal[2]); |
|
533 |
} |
|
534 |
|
|
469 | 535 |
[TestMethod] |
470 | 536 |
public void GetPredictionForTimeInvalidInput() |
471 | 537 |
{ |
Také k dispozici: Unified diff
re #9037 Adding a couple of JisParser tests