Ejemplo n.º 1
0
        public void CalculatorDestinationBellowPercent()
        {
            DeserializeLanguage();
            Language language = Languages.GetLanguage("sl-SI");
            Assert.IsNotNull(language, "Language is null!");

            HtmlDocument htmlDocument = new HtmlDocument();
            htmlDocument.Load("..\\..\\Test Files\\Marketplace.php.html");
            HtmlParser htmlParser = new HtmlParser(htmlDocument, language);
            MarketPlace marketPlaceDestination = htmlParser.MarketPlace();
            Assert.IsNotNull(marketPlaceDestination, "NULL");
            Village destinationVillage = new Village();
            destinationVillage.AddId(123).AddName("01");
            Production productionDestination = htmlParser.GetProduction();
            Assert.IsNotNull(productionDestination, "NULL");
            destinationVillage.UpdateProduction(productionDestination);

            htmlDocument = new HtmlDocument();
            htmlDocument.Load("..\\..\\Test Files\\Marketplace.idle.php.html");
            htmlParser = new HtmlParser(htmlDocument, language);
            MarketPlace marketPlaceSource = htmlParser.MarketPlace();
            Assert.IsNotNull(marketPlaceSource, "NULL");
            Village sourceVillage = new Village();
            sourceVillage.AddId(321).AddName("02");
            Production productionSource = htmlParser.GetProduction();
            Assert.IsNotNull(productionSource, "NULL");
            sourceVillage.UpdateProduction(productionSource);

            DateTime dt = new DateTime(DateTime.Now.Ticks);
            MarketPlaceQueue queue = new MarketPlaceQueue
                {
                    DestinationVillage = destinationVillage,
                    SourceVillage = sourceVillage,
                    Goods = 80,
                    SendWood = true,
                    SendClay = true,
                    SendIron = true,
                    SendCrop = true,
                    SendGoodsType = SendGoodsType.DestinationBellowPercent,
                    LastSend = dt.AddDays(-1),
                    RepeatMinutes = 10,
                };

            MarketPlaceCalculator calculator = new MarketPlaceCalculator
                {
                    Destination = destinationVillage,
                    Source = sourceVillage,
                    MarketPlaceDestination = marketPlaceDestination,
                    MarketPlaceSource = marketPlaceSource,
                    Queue = queue,
                };
            calculator.Calculate();
            Assert.AreEqual("&r1=0&r2=1246&r3=1004&r4=0", calculator.PostParameters, "PostParameters");
            Assert.IsTrue(calculator.TimeToSend(dt), "Last send time");
        }
Ejemplo n.º 2
0
 public void ParseProduction()
 {
     HtmlDocument htmlDocument = new HtmlDocument();
     htmlDocument.Load("..\\..\\Test Files\\dorf1.php.html");
     HtmlParser htmlParser = new HtmlParser(htmlDocument);
     Village village = new Village();
     village.AddId(123).AddName("01");
     Production production = htmlParser.GetProduction();
     Assert.IsNotNull(production, "NULL");
     village.UpdateProduction(production);
     Assert.AreEqual(production, village.Production, "production");
     Assert.AreEqual(575, village.Production.WoodPerHour, "wood per hour");
     Assert.AreEqual(590, village.Production.ClayPerHour, "clay per hour");
     Assert.AreEqual(525, village.Production.IronPerHour, "iron per hour");
     Assert.AreEqual(359, village.Production.CropPerHour, "crop per hour");
     Assert.AreEqual(4675, village.Production.WoodTotal, "wood total");
     Assert.AreEqual(3343, village.Production.ClayTotal, "clay total");
     Assert.AreEqual(4463, village.Production.IronTotal, "iron total");
     Assert.AreEqual(5236, village.Production.CropTotal, "crop total");
     Assert.AreEqual(14400, village.Production.Warehouse, "warehouse");
     Assert.AreEqual(11800, village.Production.Granary, "granary");
 }
Ejemplo n.º 3
0
        public void Account()
        {
            Account account = new Account();
            const string accountName = "kekec";
            const int accountId = 123;
            const TribeTypes accountTribe = TribeTypes.Gauls;
            account.AddName(accountName).AddId(accountId).AddTribe(accountTribe);
            Assert.IsNotNull(account, "Account is null!");
            Assert.AreEqual(accountName, account.Name);
            Assert.AreEqual(accountId, account.Id);
            Assert.AreEqual(accountTribe, account.TribeType);

            Village firstVillage = new Village();
            const int firstVillageId = 0;
            const string firstVillageName = "01";
            firstVillage.AddId(firstVillageId).AddName(firstVillageName);
            account.AddVillage(firstVillage);
            Assert.IsNotNull(account.Villages, "Village list!");
            Assert.AreEqual(1, account.Villages.Count, "Village list count!");
            Assert.AreEqual(firstVillageId, account.Villages[0].Id, "Village id!");
            Assert.AreEqual(firstVillageName, account.Villages[0].Name, "Village name!");

            Village secondVillage = new Village();
            const int secondVillageId = 1324;
            const string secondVillageName = "02";
            secondVillage.AddId(secondVillageId).AddName(secondVillageName);
            Production production = new Production();
            production
                .UpdateWarehouse(3100)
                .UpdateGranary(4000)
                .UpdateTotals(132, 213, 11, 223)
                .UpdatePerHour(100, 200, 300, 400);
            secondVillage.UpdateProduction(production);
            account.AddVillage(secondVillage);

            Assert.AreEqual(2, account.Villages.Count, "Village list count!");

            Village firstAccountVillage = account.GetVillage(firstVillageId);
            Assert.IsNotNull(firstAccountVillage, "Village not found!");
            Assert.AreEqual(firstVillageId, firstAccountVillage.Id, "Village id!");
            Assert.AreEqual(firstVillageName, firstAccountVillage.Name, "Village name!");
            Assert.IsNull(firstAccountVillage.Production, "Village production!");
            Assert.IsNull(firstAccountVillage.TroopsAvailable, "Village troops!");

            Village secondAccountVillage = account.GetVillage(secondVillageId);
            Assert.IsNotNull(secondAccountVillage, "Village not found!");
            Assert.AreEqual(secondVillageId, secondAccountVillage.Id, "Village id!");
            Assert.AreEqual(secondVillageName, secondAccountVillage.Name, "Village name!");
            Assert.AreEqual(production, secondAccountVillage.Production, "Village production!");
            Assert.IsNull(secondAccountVillage.TroopsAvailable, "Village troops!");

            Gauls gauls = new Gauls();
            TroopUnit phalanx = gauls.Phalanx.AddTroopCount(123);
            TroopUnit haeduan = gauls.Haeduan.AddTroopCount(13);
            Romans romans = new Romans();
            TroopUnit legionnaire = romans.Legionnaire.AddTroopCount(2222);
            TroopUnit praetorian = romans.Praetorian.AddTroopCount(45632);
            Teutons teutons = new Teutons();
            TroopUnit spearman = teutons.Spearman.AddTroopCount(5123);
            Troops troops = new Troops();
            troops
                .AddTroopUnit(phalanx).AddTroopUnit(haeduan)
                .AddTroopUnit(legionnaire).AddTroopUnit(praetorian)
                .AddTroopUnit(spearman);
            secondAccountVillage.UpdateTroopsInVillage(troops);
            Assert.IsNull(firstAccountVillage.TroopsAvailable, "Village troops!");
            Assert.IsNotNull(secondAccountVillage.TroopsAvailable, "Village troops!");
            Assert.AreEqual(13, secondAccountVillage.TroopsAvailable.GetTroopCount("unit u26"), "Haeduan count!");
        }