コード例 #1
0
        public void ReturnRemainingProteinIntake_WhenInvokedWithValidParameters()
        {
            // Arrange
            var suggestedDailyProteinIntake = 99;

            var firstProduct  = new Mock <IProduct>();
            var secondProduct = new Mock <IProduct>();

            firstProduct
            .SetupGet(m => m.Protein)
            .Returns(20);

            secondProduct
            .SetupGet(m => m.Protein)
            .Returns(25);

            var expectedResult = 54; // 99 - 45
            ICollection <IProduct> productConsumed = new List <IProduct> {
                firstProduct.Object, secondProduct.Object
            };
            var dailyNutriCalcMock = new DailyNutriCalc();

            // Act
            var actualResult = dailyNutriCalcMock.RemainingProteinIntake(suggestedDailyProteinIntake, productConsumed);

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #2
0
        public void ReturnSuggestedProteinIntake_WhenProductsConsumedAreNull()
        {
            // Arrange
            var suggestedDailyProteinIntake = 99;
            var expectedResult = suggestedDailyProteinIntake;

            var dailyNutriCalcMock = new DailyNutriCalc();

            // Act
            var actualResult = dailyNutriCalcMock.RemainingProteinIntake(suggestedDailyProteinIntake, null);

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }