Пример #1
0
        public void BodyMassIndexTest_HeightAndWeightLittleOrMoreError()
        {
            // arrange
            var modelLittle = new BodyMassIndexQuery
            {
                Height = 139,
                Weight = 29
            };

            var modelMore = new BodyMassIndexQuery
            {
                Height = 351,
                Weight = 501
            };

            // act
            var handler     = new BodyMassIndexHandler();
            var errorModel1 = handler.Handle(modelLittle).Exception.GetErrorListResponseFromException();
            var errorModel2 = handler.Handle(modelMore).Exception.GetErrorListResponseFromException();

            // assert
            Assert.IsTrue(errorModel1 != null);
            Assert.IsTrue(errorModel1.Errors.Count == 2);
            Assert.IsTrue(errorModel1.Errors.Contains(BodyMassIndexQueryValidator.HeightIncorrectMessage));
            Assert.IsTrue(errorModel1.Errors.Contains(BodyMassIndexQueryValidator.WeightIncorrectMessage));

            Assert.IsTrue(errorModel2 != null);
            Assert.IsTrue(errorModel2.Errors.Count == 2);
            Assert.IsTrue(errorModel2.Errors.Contains(BodyMassIndexQueryValidator.HeightIncorrectMessage));
            Assert.IsTrue(errorModel2.Errors.Contains(BodyMassIndexQueryValidator.WeightIncorrectMessage));
        }
Пример #2
0
        public void BodyMassIndexTest_NotError()
        {
            // arrange
            var model = new BodyMassIndexQuery
            {
                Height = 180,
                Weight = 100
            };

            // act
            var handler = new BodyMassIndexHandler();
            var result  = handler.Handle(model).Result;

            // assert
            Assert.AreEqual(30.9, result.Index);
        }
Пример #3
0
 public BodyMassIndexController(BodyMassIndexHandler bodyMassIndexHandler)
 {
     _bodyMassIndexHandler = bodyMassIndexHandler;
 }