Пример #1
0
        public void CalculateTotalStops_WhenRangeCalculationZero_ThrowsDivideByZeroException()
        {
            var moqFactory = new Mock <IRangeCalculationStrategyFactory>();

            moqFactory.Setup(mf => mf.GetRangeCalculationStrategy(It.IsAny <IntervalUnit>()))
            .Returns(CreateMoqStrategy(0).Object);

            var testCalculator = new StopsCalculator(moqFactory.Object, new Mock <ILogger>().Object);

            Assert.Throws <DivideByZeroException>(() => testCalculator.CalculateTotalStops(StarshipUtils.Create(IntervalUnit.Day, 2, 1), 1));
        }
Пример #2
0
        public void CalculateTotalStops_WhenRangeCalculationNotNull_ReturnsValidResult()
        {
            var moqFactory = new Mock <IRangeCalculationStrategyFactory>();

            moqFactory.Setup(mf => mf.GetRangeCalculationStrategy(It.IsAny <IntervalUnit>()))
            .Returns(CreateMoqStrategy(2).Object);

            var testCalculator = new StopsCalculator(moqFactory.Object, new Mock <ILogger>().Object);
            var result         = testCalculator.CalculateTotalStops(StarshipUtils.Create(IntervalUnit.Day, 2, 1), 5);

            Assert.True(result.IsValid);
            Assert.Equal(2, result.NumberOfStops);
        }