private void Form1_Load(object sender, EventArgs e)
        {
            DialogResult dialogResult = entry.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                if (!userManager.Validate(entry.Login, entry.Password))
                {
                    entry.ErrorMessage = "Error data!";
                    Form1_Load(this, e);
                }
                else
                {
                    currentUser  = userManager.FindByLogin(entry.Login);
                    this.Visible = true;
                    this.Text    = currentUser.Login;
                    CalorieRange range = userManager.GetNorm(currentUser);
                    label4.Text = range.Min + " - " + range.Max + " kcal";
                }
            }
            else
            {
                if (dialogResult == DialogResult.Yes)
                {
                    RegistrationForm form = new RegistrationForm();
                    dialogResult = form.ShowDialog();
                    if (dialogResult == DialogResult.OK)
                    {
                        if (userManager.IsExists(form.User.Login))
                        {
                            entry.ErrorMessage = "This user already exist";
                        }
                        else
                        {
                            try
                            {
                                userManager.Create(form.User);
                            }
                            catch (Exception ex)
                            {
                                entry.ErrorMessage = "Wrong data:" + ex.Message;
                            }
                        }
                        Form1_Load(this, e);
                    }
                    else
                    {
                        userManager.Dispose();
                        this.Close();
                    }
                }
                userManager.Dispose();
                this.Close();
            }
        }
Exemplo n.º 2
0
        public void TestCalorieRange_GenderIsFemaleCaloriesAreExcessive_ReturnExcessive()
        {
            //Arrange
            BMI bmi = new BMI();

            bmi.PersonGender   = "female";
            bmi.CaloriesIntake = 5000;

            //Act
            CalorieRange expectedResult = bmi.CalorieRange;

            //Assert
            Assert.AreEqual(CalorieRange.Excessive, expectedResult);
        }
Exemplo n.º 3
0
        public void TestCalorieRange_GenderIsFemaleCaloriesAreHigh_ReturnHigh()
        {
            //Arrange
            BMI bmi = new BMI();

            bmi.PersonGender   = "female";
            bmi.CaloriesIntake = 3200;

            //Act
            CalorieRange expectedResult = bmi.CalorieRange;

            //Assert
            Assert.AreEqual(CalorieRange.High, expectedResult);
        }
Exemplo n.º 4
0
        public void TestCalorieRange_GenderIsMaleCaloriesAreAverage_ReturnAverage()
        {
            //Arrange
            BMI bmi = new BMI();

            bmi.PersonGender   = "male";
            bmi.CaloriesIntake = 2500;

            //Act
            CalorieRange expectedResult = bmi.CalorieRange;

            //Assert
            Assert.AreEqual(CalorieRange.Average, expectedResult);
        }
Exemplo n.º 5
0
        public void TestCalorieRange_GenderIsMaleCaloriesAreLow_ReturnLow()
        {
            //Arrange
            BMI bmi = new BMI();

            bmi.PersonGender   = "male";
            bmi.CaloriesIntake = 1800;

            //Act
            CalorieRange expectedResult = bmi.CalorieRange;

            //Assert
            Assert.AreEqual(CalorieRange.Low, expectedResult);
        }