Inheritance: Entity, ILookUpTypes
 public void shouldGetGenderType()
 {
     var genderTypeRepositoryMock = new Mock<IGenderTypeRepository>();
     var expectedGenderType = new GenderType();
     genderTypeRepositoryMock.Setup(x => x.GetByName(It.IsAny<string>())).Returns(expectedGenderType);
     var result = new GenderTypeBusinessLogic(genderTypeRepositoryMock.Object).GetGenderType("Man");
     Assert.That(result, Is.SameAs(expectedGenderType));
 }
Ejemplo n.º 2
0
 public void shouldGetBMR()
 {
     const decimal weight = 59;
     const decimal height = 168;
     const int age = 55;
     var female = new GenderType {GenderBMRFactor = -161};
     var bmr = new CalorieCalculator().GetBMR(weight, height, age, female);
     Assert.That(bmr, Is.EqualTo(1207.81m));
 }
        public void shouldGetUserGender()
        {
            var expectedValue = new GenderType();
            var userProfileBusinessLogicMock = new Mock<IUserProfileBusinessLogic>();
            userProfileBusinessLogicMock.Setup(x => x.GetGender(It.IsAny<User>())).Returns(expectedValue);

            GenderType result = new MineralRDICalculator(null, userProfileBusinessLogicMock.Object).GetUserGender(new User());
            Assert.That(result, Is.EqualTo(expectedValue));
        }
Ejemplo n.º 4
0
 public void shouldGetDailyCalorieNeed()
 {
     const decimal weight = 59;
     const decimal height = 168;
     const int age = 55;
     var female = new GenderType {GenderBMRFactor = -161};
     var activityLevel = new ActivityLevelType { EnergyFactor = 1.2M };
     var dailyCalorieNeed = new CalorieCalculator().GetDailyCalorieNeed(weight, height, age, female, activityLevel);
     Assert.That(dailyCalorieNeed, Is.EqualTo(1449.372m));
 }
        public void shouldGetStoredGenderForLoggedinUserAsSelectListItem()
        {
            var expectedGender = new GenderType { Name = "selected" };

            var userProfileBusinessLogicMock = new Mock<IUserProfileBusinessLogic>();
            userProfileBusinessLogicMock.Setup(x => x.GetGender(It.IsAny<User>())).Returns(expectedGender);

            var genderBusinessLogicMock = new Mock<IGenderTypeBusinessLogic>();
            genderBusinessLogicMock.Setup(x => x.GetGenderTypes()).Returns(new List<GenderType> { new GenderType { Name = "selected" }, new GenderType { Name = "notSelected" } });

            var genderViewTypes = new GenderViewTypeConverter(userProfileBusinessLogicMock.Object, genderBusinessLogicMock.Object).GetViewTypes(new User());

            var selectedGender = (from gen in genderViewTypes where gen.Selected select gen).FirstOrDefault();

            userProfileBusinessLogicMock.VerifyAll();
            Assert.That(selectedGender.Text, Is.SameAs(expectedGender.Name));
        }
        public void shouldGetRDI()
        {
            const decimal proteinRDI = 1.2M;
            var nutrientRecommendationBusinessLogicMock = new Mock<INutrientRecommendationBusinessLogic>();
            nutrientRecommendationBusinessLogicMock.Setup(x => x.GetNutrientRecommendation(NutrientEntity.ProteinInG)).Returns(createRecommendation(proteinRDI));

            const decimal weight = 75M;
            const int age = 32;
            var gender = new GenderType{Name = "Man"};
            var userProfileBusinessLogicMock = new Mock<IUserProfileBusinessLogic>();
            userProfileBusinessLogicMock.Setup(x => x.GetWeight(It.IsAny<User>())).Returns(weight);
            userProfileBusinessLogicMock.Setup(x => x.GetAge(It.IsAny<User>())).Returns(age);
            userProfileBusinessLogicMock.Setup(x => x.GetGender(It.IsAny<User>())).Returns(gender);

            decimal result = new MineralRDICalculator(nutrientRecommendationBusinessLogicMock.Object, userProfileBusinessLogicMock.Object).GetRDI(new User(), DateTime.Now, NutrientEntity.ProteinInG);

            Assert.That(result, Is.EqualTo(proteinRDI));
        }
        public void shouldGetBMR()
        {
            const decimal weight = 83M;
            const int age = 24;
            const int height = 174;
            var gender = new GenderType{Name="Man"};
            var activityLevel = new ActivityLevelType { Name = "Medel" };
            var calorieCalculator = new Mock<ICalorieCalculator>();

            var userProfile = new UserProfile { Weight = weight, Age = age, Length = height , Gender = gender, ActivityLevel = activityLevel,  User = User };

            var userProfileRepositoryMock = new Mock<IUserProfileRepository>();
            userProfileRepositoryMock.Setup(x => x.GetByUserId(User.Id)).Returns(userProfile);

            calorieCalculator.Setup(x => x.GetBMR(weight, height, age, gender)).Returns(123);

            var result = new UserProfileBusinessLogic(userProfileRepositoryMock.Object, null, null, calorieCalculator.Object).GetBMR(User);

            Assert.That(result, Is.EqualTo(123));
        }
Ejemplo n.º 8
0
 //http://www.bmi-calculator.net/bmr-calculator/harris-benedict-equation/
 public decimal GetDailyCalorieNeed(decimal weight, decimal height, int age, GenderType gender, ActivityLevelType activityLevel)
 {
     return GetBMR(weight, height, age, gender) * activityLevel.EnergyFactor;
 }
Ejemplo n.º 9
0
 //http://en.wikipedia.org/wiki/Basal_metabolic_rate
 public decimal GetBMR(decimal weight, decimal height, int age, GenderType gender)
 {
     return GetWeightFactor(weight) + GetHeightFactor(height) - GetAgeFactor(age) + gender.GenderBMRFactor;
 }
        public void shouldSaveProfile()
        {
            const decimal expectedIdealWeight = 64;
            const decimal expectedLength = 1.83M;
            const decimal expectedWeight = 78M;
            const int expectedAge = 23;
            const string expectedGenderToGet = "Man";
            const string expectedActivityLevelToGet = "Medel";
            var expectedGender = new GenderType();
            var expectedActivityLevel = new ActivityLevelType();

            var genderTypeBusinessLogicMock = new Mock<IGenderTypeBusinessLogic>();
            genderTypeBusinessLogicMock.Setup(x => x.GetGenderType(expectedGenderToGet)).Returns(expectedGender);

            var activityLevelTypeBusinessLogicMock = new Mock<IActivityLevelTypeBusinessLogic>();
            activityLevelTypeBusinessLogicMock.Setup(x => x.GetActivityLevelType(expectedActivityLevelToGet)).Returns(expectedActivityLevel);

            var userProfileRepositoryMock = new Mock<IUserProfileRepository>();
            userProfileRepositoryMock.Setup(x => x.SaveOrUpdate(It.Is<UserProfile>(y => y.Weight == expectedWeight && y.Length == expectedLength && y.IdealWeight == expectedIdealWeight && y.User.Id == User.Id && y.Age == expectedAge && y.Gender == expectedGender && y.ActivityLevel == expectedActivityLevel)));

            new UserProfileBusinessLogic(userProfileRepositoryMock.Object, genderTypeBusinessLogicMock.Object, activityLevelTypeBusinessLogicMock.Object, null).SaveProfile(User, expectedIdealWeight, expectedLength, expectedWeight, expectedAge, expectedGenderToGet, expectedActivityLevelToGet);
            userProfileRepositoryMock.VerifyAll();
            activityLevelTypeBusinessLogicMock.VerifyAll();
        }
 public void shouldGetGender()
 {
     var expectedGender = new GenderType();
     var userProfile = new UserProfile { Gender = expectedGender, User = User };
     AssertProperty(expectedGender, User, userProfile, x => x.GetGender(User));
 }