public void GetBehavior()
 {
     Assert.AreEqual(ChildBehavior.None, ChildBehaviorHelper.GetBehavior(0));
     Assert.AreEqual(ChildBehavior.Curious, ChildBehaviorHelper.GetBehavior(2));
     Assert.AreEqual(ChildBehavior.Shy, ChildBehaviorHelper.GetBehavior(7));
     Assert.AreEqual(ChildBehavior.Hyperactive, ChildBehaviorHelper.GetBehavior(16));
 }
Example #2
0
        private void CalculateBehavior()
        {
            RupeesGiven   rupeesGiven   = 0;
            SleepMethod   method        = 0;
            KindOfChild   kindOfChild   = 0;
            ChildQuestion childQuestion = 0;

            RadioButton radioButton = ugRupeesGiven.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked ?? false);

            if (radioButton != null)
            {
                Enum.TryParse(radioButton.Tag.ToString(), out rupeesGiven);
            }

            radioButton = ugSleepMethod.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked ?? false);
            if (radioButton != null)
            {
                Enum.TryParse(radioButton.Tag.ToString(), out method);
            }

            radioButton = ugKindOfChild.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked ?? false);
            if (radioButton != null)
            {
                Enum.TryParse(radioButton.Tag.ToString(), out kindOfChild);
            }

            radioButton = ugChildQuestion.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked ?? false);
            if (radioButton != null)
            {
                Enum.TryParse(radioButton.Tag.ToString(), out childQuestion);
            }

            CalculatedTotal    = ChildBehaviorHelper.GetValue(_gameInfo?.Region ?? GameRegion.US, txtChildName.Text, rupeesGiven, method, childQuestion, kindOfChild);
            CalculatedBehavior = ChildBehaviorHelper.GetBehavior(CalculatedTotal);

            if (_gameInfo != null)
            {
                _gameInfo.Child    = txtChildName.Text;
                _gameInfo.Behavior = CalculatedTotal;
            }
        }