Пример #1
0
        public void GetIdealBodyWeightFromDataSource_Using_FakeItEasy()
        {
            List <WeightCalculator> weights = new List <WeightCalculator>()
            {
                new WeightCalculator()
                {
                    Height = 175, Gender = 'm'
                },
                new WeightCalculator()
                {
                    Height = 172, Gender = 'm'
                },
                new WeightCalculator()
                {
                    Height = 175, Gender = 'w'
                }
            };
            var repo = new A.fake <IDataRepository>();

            //repo.Setup(w => w.GetWeights()).Returns(weights);
            A.CallTo(() => repo.getWeight()).returns(weights);
            WeightCalculator weightCalculator = new WeightCalculator(repo);
            var actual = weightCalculator.GetIdealBodyWeightFromDataSource();

            double[] expected = { 62.5, 62.75 };
            actual.Should().Equal(expected);
        }
Пример #2
0
        public void GetIdealBodyWeightFromDataSource_Using_Moq()
        {
            List <WeightCalculator> weights = new List <WeightCalculator>()
            {
                new WeightCalculator()
                {
                    Height = 175, Gender = 'm'
                },
                new WeightCalculator()
                {
                    Height = 172, Gender = 'm'
                },
                new WeightCalculator()
                {
                    Height = 175, Gender = 'w'
                }
            };
            mock <IDataRepository> repo = new mock <IDataRepository>();

            repo.Setup(w => w.GetWeights()).Returns(weights);
            WeightCalculator weightCalculator = new WeightCalculator(repo.Object);
            var actual = weightCalculator.GetIdealBodyWeightFromDataSource();

            double[] expected = { 62.5, 62.75 };
            actual.Should().Equal(expected);
        }
Пример #3
0
        public void GetIdealBodyWeightFromDataSource_WithGoodinputs_Returns_Correct_Results()
        {
            WeightCalculator weightCalculator = new WeightCalculator(new FakeWeightRepository());
            List <double>    actual           = weightCalculator.GetIdealBodyWeightFromDataSource();

            double[] expected = { 62.5, 62.75, 74 };
            CollectionAssertion.AreEqual(expected, actual);
        }
        public void GetIdealBodyWeightFromDataSource_WithGoodInputs_Returns_Correct_Results()
        {
            WeightCalculator weightCalculator = new WeightCalculator(new FakeWeightRepository());

            List <double> actual = weightCalculator.GetIdealBodyWeightFromDataSource();

            double[] expected = { 62.5, 62.75, 74 };

            actual.Should().BeEquivalentTo(expected);
        }
        public void GetIdealBodyWeightFromDataSource_Using_FakeItEasy()
        {
            List <WeightCalculator> weights = new List <WeightCalculator>()
            {
                new WeightCalculator {
                    Height = 175, Sex = 'w'
                },                                               // 62.5
                new WeightCalculator {
                    Height = 167, Sex = 'm'
                },                                               // 62.75
            };

            IDataRepository repo = A.Fake <IDataRepository>();

            A.CallTo(() => repo.GetWeights()).Returns(weights);

            WeightCalculator calculator = new WeightCalculator(repo);

            var actual = calculator.GetIdealBodyWeightFromDataSource();

            double[] expected = { 62.5, 62.75 };

            actual.Should().Equal(expected);
        }