Esempio n. 1
0
 public void Merchants35()
 {
     string pageSource = Misc.ReadContent("..\\..\\..\\Samples\\TestFiles\\build.php-newdid=73229-gid=17");
     HtmlParser htmlParser = new HtmlParser(pageSource);
     Marketplace marketplace = new Marketplace();
     const int villageId = 73229;
     marketplace.VillageId = villageId;
     htmlParser.ParseMarketplace(marketplace);
     Assert.AreEqual(0, marketplace.AvailableMerchants);
     Assert.AreEqual(20, marketplace.TotalMerchants);
     Assert.AreEqual(2000, marketplace.TotalCarry);
     Village village = new Village(villageId, "some name");
     htmlParser.ParseVillageProduction(village);
     Assert.AreEqual(3736, village.WoodAvailable);
     Assert.AreEqual(1000, village.WoodProduction);
     Assert.AreEqual(3736, village.ClayAvailable);
     Assert.AreEqual(1000, village.ClayProduction);
     Assert.AreEqual(5036, village.IronAvailable);
     Assert.AreEqual(1000, village.IronProduction);
     Assert.AreEqual(15804, village.CropAvailable);
     Assert.AreEqual(442, village.CropProduction);
     Assert.AreEqual(160000, village.CapacityWarehouse);
     Assert.AreEqual(160000, village.CapacityGranary);
 }
Esempio n. 2
0
 public void ParseMarketplace(Marketplace marketplace)
 {
     //<tr><td colspan="2">Trgovci 4/20<br><br></td></tr>
     string patternMerchants = String.Format(CultureInfo.InvariantCulture, @"<tr><td colspan=""2"">{0} (\d+)/(\d+)<br><br></td></tr>", Misc.GetConfigValue("availableMerchantsString"));
     Regex merchants = new Regex(patternMerchants);
     if (merchants.IsMatch(pageSource))
     {
         Match Mc = merchants.Matches(pageSource)[0];
         marketplace.AvailableMerchants = Int32.Parse(Mc.Groups[1].Value.Trim());
         marketplace.TotalMerchants = Int32.Parse(Mc.Groups[2].Value.Trim());
     }
     //<p>Vsak tvoj trgovec lahko prepelje <b>2000</b>
     string patternCarryMerchants = String.Format(CultureInfo.InvariantCulture, @"<p>{0} <b>(\d+)</b>", Misc.GetConfigValue("carryString"));
     Regex carry = new Regex(patternCarryMerchants);
     if (carry.IsMatch(pageSource))
     {
         Match Mc = carry.Matches(pageSource)[0];
         marketplace.TotalCarry = Int32.Parse(Mc.Groups[1].Value.Trim());
     }
 }