Exemplo n.º 1
0
 public AccountRegister(Panel PrincipalPanel, IParkingRepository ParkingRepository, CountryHandler ActualCountry)
 {
     InitializeComponent();
     Panel          = PrincipalPanel;
     Repository     = ParkingRepository;
     CountryHandler = ActualCountry;
 }
Exemplo n.º 2
0
        public void ValidateRepeatCountry()
        {
            CountryHandler Country = new CountryHandler("Brasil", 2);

            Repository.AddCountry(Country);
            Assert.AreEqual(true, Repository.IsRepeatedCountry("Brasil"));
        }
Exemplo n.º 3
0
 public void TestInit()
 {
     Uruguay   = new CountryHandler("Uruguay", 1);
     Argentina = new CountryHandler("Argentina", 1);
     Uruguay.SetValidators(new ValidatorOfPhoneInUruguay(), new ValidatorOfMessageInUruguay());
     Argentina.SetValidators(new ValidatorOfPhoneInArgentina(), new ValidatorOfMessageInArgentina());
 }
Exemplo n.º 4
0
        public IActionResult Manage()
        {
            List <CountryModel> countrylist = new List <CountryModel>();

            countrylist = new CountryHandler().GetCountries().ToCountryList();
            return(View(countrylist));
        }
Exemplo n.º 5
0
        public void ValidateRepeatCountryNotRepeated()
        {
            Repository.GetCountries().Clear();
            CountryHandler Country = new CountryHandler("Brasil", 1);

            Repository.AddCountry(Country);
            Assert.AreEqual(false, Repository.IsRepeatedCountry(""));
        }
Exemplo n.º 6
0
        public void ValidateGrabAnCountryInTheList()
        {
            Repository.GetCountries().Clear();
            CountryHandler brasil = new CountryHandler("Brasil", 5);

            Repository.AddCountry(brasil);
            Assert.AreEqual(brasil, Repository.GetACountry("Brasil"));
        }
Exemplo n.º 7
0
    //Reset the rewards of a territory
    public void ResetRewards()
    {
        CountryHandler handler = GameObject.Find(GameManager.instance.attackedTerritory)
                                 .GetComponent <CountryHandler>();

        handler.country.expReward   = 30;  //Set base exp value
        handler.country.moneyReward = 100; //Set base money value
    }
Exemplo n.º 8
0
 public Settings(Panel PrincipalPanel, IParkingRepository Parking, CountryHandler ActualCountry)
 {
     InitializeComponent();
     Panel             = PrincipalPanel;
     ParkingRepository = Parking;
     Country           = ActualCountry;
     AgregateItemsToComboBoxs();
     SetActualData();
 }
Exemplo n.º 9
0
        public async Task <ActionResult> Result(CountryQuery query)
        {
            // var result = await _mediator.Send<CountryViewModel>(query);

            // TODO Use Mediator and depedenacy injection
            var handler = new CountryHandler(new WorldBankDataService(new DeserializerService()));
            var result  = await handler.Handle(query);

            return(View(result));
        }
Exemplo n.º 10
0
 public ProcessPurchase(Panel PrincipalPanel, IParkingRepository ParkingRepository, CountryHandler ActualCountry)
 {
     InitializeComponent();
     Panel                 = PrincipalPanel;
     Repository            = ParkingRepository;
     ValidatorOfEnrollment = new ValidatorOfEnrollment();
     ValidatorOfDate       = new ValidatorOfDate();
     CostForMinutes        = ActualCountry.CostForMinutes;
     CountryHandler        = ActualCountry;
 }
Exemplo n.º 11
0
 public Reports(Panel PrincipalPanel, IParkingRepository ParkingRepository, CountryHandler ActualCountry)
 {
     InitializeComponent();
     Panel      = PrincipalPanel;
     Repository = ParkingRepository;
     Country    = ActualCountry;
     rbtnEnrollments.Checked = true;
     AgregateItemsToComboBoxs();
     ValidatorOfEnrollment = new ValidatorOfEnrollment();
 }
Exemplo n.º 12
0
    //Set the Slider info
    public void FortifyMoveBattalions()
    {
        CountryHandler from = GameObject.Find(GameManager.instance.fortifyFrom)
                              .GetComponent <CountryHandler>();

        fortifySliderParent.SetActive(true);
        fortifySlider.maxValue = from.country.battalions - 1;
        print("Slider max:" + fortifySlider.maxValue);
        fortifySlider.minValue = 0;
        print("Slider min:" + fortifySlider.minValue);
    }
Exemplo n.º 13
0
        public async Task TestListCountriesAsync(int top, string alfa2, string alfa3, string name, string phonePrefix, short countryCode)
        {
            // arrange
            using (var tscFactory = new TscContextFactory())
            {
                using (TscContext tscContext = await tscFactory.CreateContextAsync())
                {
                    using (var tran = await tscContext.Database.BeginTransactionAsync())
                    {
                        try
                        {
                            Country c1 = new Country
                            {
                                Alfa2       = alfa2,
                                Alfa3       = alfa3,
                                PhonePrefix = phonePrefix,
                                IsoName     = name,
                                CommonName  = name,
                                CountryCode = countryCode
                            };

                            await tscContext.Countries.AddAsync(c1);

                            await tscContext.SaveChangesAsync();

                            // act
                            var handler = new CountryHandler(tscContext);
                            Tuple <CountryModel[], int> result = await handler.ListAsync(new GetCountryDetails { Top = top, Alfa2 = alfa2, Name = name });

                            // assert
                            Assert.NotNull(result);
                            Assert.Single(result.Item1.Where(x => x.Alfa2 == alfa2));

                            var country = result.Item1[0];

                            Assert.Equal(alfa2, country.Alfa2);
                            Assert.Equal(alfa3, country.Alfa3);
                            Assert.Equal(name, country.CommonName);
                            Assert.Equal(name, country.IsoName);
                            Assert.Equal(phonePrefix, country.PhonePrefix);
                            Assert.Equal(countryCode, country.CountryCode);
                        }
                        catch
                        {
                            throw;
                        }
                        finally
                        {
                            tran.Rollback();
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public PrincipalForm()
        {
            InitializeComponent();
            this.SecundaryPanel.Visible = false;
            this.PrincipalPanel.Visible = true;
            lblAnswer.Visible           = false;
            Repository = new ParkingRepository();
            CountryHandler initialCountry = Repository.GetACountry("Uruguay");

            Settings = new Settings(PrincipalPanel, Repository, initialCountry);
        }
Exemplo n.º 15
0
        public void ValidateGrabACountryInTheListOfManyCountries()
        {
            Repository.GetCountries().Clear();
            Repository.AddCountry(new CountryHandler("Argentina", 2));
            Repository.AddCountry(new CountryHandler("Chile", 3));
            Repository.AddCountry(new CountryHandler("Brasil", 2));
            CountryHandler venezuela = new CountryHandler("Venezuela", 3);

            Repository.AddCountry(venezuela);
            Assert.AreEqual(venezuela, Repository.GetACountry("Venezuela"));
        }
Exemplo n.º 16
0
        public void AddCountry()
        {
            Repository.GetCountries().Clear();
            CountryHandler Country = new CountryHandler("Brasil", 1);

            Repository.AddCountry(Country);
            Assert.AreEqual(true, Repository.GetCountries().Contains(Country));
            using (var MyContext = new MyContext())
            {
                MyContext.Countries.Attach(Country);
            }
        }
Exemplo n.º 17
0
    //Move specified amount of battalions in attack phase
    public void MoveBattalions_a()
    {
        CountryHandler def = GameObject.Find(GameManager.instance.attackedTerritory)
                             .GetComponent <CountryHandler>();

        CountryHandler win = GameObject.Find(GameManager.instance.attackFrom)
                             .GetComponent <CountryHandler>();

        win.country.battalions -= attack_amount;
        def.country.battalions += attack_amount;

        attackSliderParent.SetActive(false);
    }
Exemplo n.º 18
0
        public void AddTwoEqualsCountry()
        {
            CountryHandler Country       = new CountryHandler("Brasil", 1);
            CountryHandler secondCountry = new CountryHandler("Brasil", 2);

            Repository.AddCountry(Country);
            Repository.AddCountry(secondCountry);
            Assert.AreEqual(false, Repository.GetCountries().Contains(secondCountry));
            using (var MyContext = new MyContext())
            {
                MyContext.Countries.Attach(Country);
            }
        }
Exemplo n.º 19
0
 private void UpdateData()
 {
     if (!cboCountry.Text.Equals(""))
     {
         Country = ParkingRepository.GetACountry(cboCountry.Text);
     }
     if (Country.ValidateIsNumericByCountry(txtCostForMinutes.Text))
     {
         int NewCostOfMinutes = int.Parse(txtCostForMinutes.Text);
         Country.CostForMinutes = NewCostOfMinutes;
         ParkingRepository.UpdateCostForMinutes(Country);
     }
 }
Exemplo n.º 20
0
        public ActionResult StateInfo(string CountryCode)
        {
            ConsolidatedCountryInfo _consolidatedData = new ConsolidatedCountryInfo();
            var countryHandler = new CountryHandler();
            var states         = countryHandler.GetStatesListByCountry(CountryCode);

            states = states.Replace("\n", "");
            Country countryInfo = countryHandler.GetCountryInfo(CountryCode);

            _consolidatedData.Country   = countryInfo;
            _consolidatedData.StateList = states;
            return(View(_consolidatedData));
        }
Exemplo n.º 21
0
    //Set the Slider info
    public void AttackMoveBattalions()
    {
        //CountryHandler def = GameObject.Find(GameManager.instance.attackedTerritory)
        //.GetComponent<CountryHandler>();

        CountryHandler win = GameObject.Find(GameManager.instance.attackFrom)
                             .GetComponent <CountryHandler>();

        attackSliderParent.SetActive(true);
        attackSlider.maxValue = win.country.battalions - 1;
        print("Slider max:" + attackSlider.maxValue);
        attackSlider.minValue = 1;
        print("Slider min:" + attackSlider.minValue);
    }
Exemplo n.º 22
0
    //Move specified amount of battalions in fortify phase
    public void MoveBattalions_f()
    {
        CountryHandler to = GameObject.Find(GameManager.instance.fortifyTo)
                            .GetComponent <CountryHandler>();

        CountryHandler from = GameObject.Find(GameManager.instance.fortifyFrom)
                              .GetComponent <CountryHandler>();

        from.country.battalions -= fortify_amount;
        to.country.battalions   += fortify_amount;

        fortifySliderParent.SetActive(false);
        DisableFortifyPhasePanel();
    }
Exemplo n.º 23
0
        public void UpdateCostOfMinutes()
        {
            Repository.GetCountries().Clear();
            CountryHandler Country = new CountryHandler("Uruguay", 1);

            Country.SetValidators(new ValidatorOfPhoneInUruguay(), new ValidatorOfMessageInUruguay());
            Repository.AddCountry(Country);
            Country.CostForMinutes = 2;
            Repository.UpdateCostForMinutes(Country);
            Assert.AreEqual(2, Country.CostForMinutes);
            using (var MyContext = new MyContext())
            {
                MyContext.Countries.Attach(Country);
            }
        }
Exemplo n.º 24
0
    //Check if the game has been won
    public void CheckIfGameWon()
    {
        print("Checking if Game has been Won");
        //Loop through the list of territories
        for (int i = 0; i < territoryList.Count; i++)
        {
            CountryHandler handler = territoryList[i].GetComponent
                                     <CountryHandler>();

            //Check if it belongs to the playing race
            if (handler.country.race == GameManager.instance.CURRENTRACE)
            {
                winCount++;
            }
        }

        //Game not won
        if (winCount < 42)
        {
            print("Game not Won");
            GameManager.instance.gameActive = true;

            winCount = 0;
        }

        //Game won
        if (winCount >= 42)
        {
            GameOverPanel gameover = gameOverPanel.GetComponent <GameOverPanel>();

            print("Game Won!!!");

            //Show game over panel
            GameManager.instance.gameActive = true;

            draftPanel.SetActive(false);
            attackPhasePanel.SetActive(false);
            attackPanel.SetActive(false);
            fortifyPhasePanel.SetActive(false);
            Menu.SetActive(false);
            GUI.SetActive(false);
            battalionsPanel.SetActive(false);
            gameOverPanel.SetActive(true);
            gameover.Winner.text = "Congratulations " + GameManager.instance.CURRENTRACE + "! You've dominated the Galaxy";

            GameManager.instance.gameActive = false;
        }
    }
Exemplo n.º 25
0
        public void Constructor_NullWorldBankDataService_ThrowsArgumentNullException()
        {
            // Arrange
            const string expectedExceptionParamName = "worldBankDataService";

            // Act & assert
            try
            {
                var handler = new CountryHandler(null);
                Assert.Fail("Passing a null worldBankDataService into CountryHandler constructor should throw ArgumentNullException");
            }
            catch (ArgumentNullException exp)
            {
                Assert.AreEqual(expectedExceptionParamName, exp.ParamName);
            }
        }
Exemplo n.º 26
0
    //Méthode permettant de récupérer et désactiver les territoires (pour les collisions avec le dé)
    public void Fight()
    {
        //Récupère la liste de touts les territoires et les désactives
        for (int i = 0; i < countryList.Count; i++)
        {
            CountryHandler countHandler = countryList[i].GetComponent <CountryHandler>();
            countryList[i].SetActive(false);
        }

        //Indique si tous les territoires ont été désactivés
        if (!countryList[(countryList.Count) - 1].activeSelf)
        {
            active = true;
        }

        nbDe = this.valueDe;
        nbAt = this.valueDeAttacked;
    }
Exemplo n.º 27
0
    //Colour the territories
    public void TintTerritories()
    {
        print("Tinting Territories");
        //For every territory in the territory list
        for (int i = 0; i < territoryList.Count; i++)
        {
            CountryHandler handler = territoryList[i].GetComponent
                                     <CountryHandler>();

            //Purple
            if (handler.country.race == "AVIAN")
            {
                handler.TintColor(new Color32(255, 0, 255, 100));
            }
            //Blue
            if (handler.country.race == "EVREI")
            {
                handler.TintColor(new Color32(0, 0, 255, 100));
            }
            //Green
            if (handler.country.race == "HUMAN")
            {
                handler.TintColor(new Color32(0, 255, 0, 100));
            }
            //Red
            if (handler.country.race == "KABAL")
            {
                handler.TintColor(new Color32(255, 0, 0, 100));
            }
            //Yellow
            if (handler.country.race == "TENNO")
            {
                handler.TintColor(new Color32(255, 255, 0, 100));
            }
            //Cyan
            if (handler.country.race == "VORTA")
            {
                handler.TintColor(new Color32(0, 255, 255, 100));
            }
        }
        print("Territories Tinted!");
    }
Exemplo n.º 28
0
        public async Task Handle_ValidInvoke_CallsLoadCountry()
        {
            // Arrange
            var query = new CountryQuery
            {
                Iso2Code = "br"
            };

            var worldBankDataServiceMock = new Mock <IWorldBankDataService>();

            worldBankDataServiceMock.Setup(x => x.LoadCountry(query.Iso2Code)).ReturnsAsync(new Models.WorldBank.Country());

            var handler = new CountryHandler(worldBankDataServiceMock.Object);

            // Act
            await handler.Handle(query);

            // Asset
            worldBankDataServiceMock.Verify(x => x.LoadCountry(query.Iso2Code), Times.Exactly(1));
        }
Exemplo n.º 29
0
        public async Task Handle_CountryLoaded_MapsToViewModel()
        {
            // Arrange
            var query = new CountryQuery
            {
                Iso2Code = "br"
            };

            var country = new Models.WorldBank.Country
            {
                Iso2Code    = "br",
                CapitalCity = "capital city",
                Name        = "My city",
                Longitude   = 34.4545d,
                Latitude    = -3.5658787d,
                AdminRegion = "Admin region"
            };

            var expectedCountryViewModel = new CountryViewModel
            {
                Iso2Code    = country.Iso2Code,
                CapitalCity = country.CapitalCity,
                AdminRegion = country.AdminRegion,
                Longitude   = country.Longitude,
                Latitude    = country.Latitude,
                Name        = country.Name
            };


            var worldBankDataServiceMock = new Mock <IWorldBankDataService>();

            worldBankDataServiceMock.Setup(x => x.LoadCountry(query.Iso2Code)).ReturnsAsync(country);

            var handler = new CountryHandler(worldBankDataServiceMock.Object);

            // Act
            var actualCountryViewModel = await handler.Handle(query);

            // Assert
            Assert.IsTrue(expectedCountryViewModel.IsDeepEqual(actualCountryViewModel));
        }
        /// <summary>
        /// Helper Method that executes the test
        /// </summary>
        /// <param name="country"></param>
        /// <param name="image"></param>
        private void Execute_GetImageForCountry_SeveralTests(string country, string image)
        {
            #region Arrange

            string expected = image;
            CountryHandler target = new CountryHandler();

            #endregion

            #region Act

            string actual = target.GetImageForCountry(country);

            #endregion

            #region Assert

            Assert.AreEqual(expected, actual);

            #endregion
        }
Exemplo n.º 31
0
    //void OnMouseEnter()
    //{
    //    oldColor = sprite.color;
    //    if (!ManageGame.instance.playerTurn || country.controllingPlayer.ToString() == ManageGame.instance.playerTribe)
    //    {
    //        hoverColor = oldColor;
    //    }
    //    else if (country.controllingPlayer.ToString() != ManageGame.instance.playerTribe)
    //    {
    //        hoverColor = new Color32(oldColor.r, oldColor.g, oldColor.b, 250);
    //    }
    //    sprite.color = hoverColor;
    //}

    //void OnMouseExit()
    //{
    //    sprite.color = oldColor;
    //}

    // Method that shows attack panel if country not owned by player
    private void OnMouseUpAsButton()
    {
        // Checks the player owns a neighbouring country to the country clicked on
        bool neighbourPlayer = false;

        foreach (var x in neighbourCountries[country.name])
        {
            CountryHandler nc = GameObject.Find(x).GetComponent <CountryHandler>();
            if (nc.country.controllingPlayer.ToString() == ManageGame.instance.playerTribe)
            {
                neighbourPlayer = true;
            }
        }
        if ((country.controllingPlayer.ToString() != ManageGame.instance.playerTribe) && ManageGame.instance.playerTurn && neighbourPlayer)
        {
            ShowGUI();
        }
        else if (country.controllingPlayer.ToString() == ManageGame.instance.playerTribe && ManageGame.instance.playerTroopAllocate)
        {
            allocateTroops();
        }
    }