public void Calculate_KernelWithCompleteOutput_OutputCorrectlyReturnedByCalculator()
        {
            // Setup
            UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create();

            using (new MacroStabilityInwardsKernelFactoryConfig())
            {
                var factory = (TestMacroStabilityInwardsKernelFactory)MacroStabilityInwardsKernelWrapperFactory.Instance;
                UpliftVanKernelStub upliftVanKernel = factory.LastCreatedUpliftVanKernel;
                SetCompleteKernelOutput(upliftVanKernel);

                SetValidKernelOutput(factory.LastCreatedWaternetDailyKernel);
                SetValidKernelOutput(factory.LastCreatedWaternetExtremeKernel);

                // Call
                UpliftVanCalculatorResult result = new UpliftVanCalculator(input, factory).Calculate();

                // Assert
                Assert.IsNotNull(result);
                Assert.AreEqual(upliftVanKernel.FactorOfStability, result.FactorOfStability);
                Assert.AreEqual(upliftVanKernel.ForbiddenZonesXEntryMax, result.ForbiddenZonesXEntryMax);
                Assert.AreEqual(upliftVanKernel.ForbiddenZonesXEntryMin, result.ForbiddenZonesXEntryMin);
                UpliftVanCalculatorOutputAssert.AssertUpliftVanSlidingCurveResult(UpliftVanSlidingCurveResultCreator.Create(upliftVanKernel.SlidingCurveResult),
                                                                                  result.SlidingCurveResult);
                UpliftVanCalculatorOutputAssert.AssertUpliftVanCalculationGridResult(UpliftVanCalculationGridResultCreator.Create(upliftVanKernel.UpliftVanCalculationGridResult),
                                                                                     result.CalculationGridResult);
            }
        }
        public void Create_WithUpliftVanCalculationGrid_ReturnUpliftVanCalculationGridResult()
        {
            // Setup
            var    random                   = new Random(21);
            double leftGridXLeft            = random.Next();
            double leftGridXRight           = random.Next();
            double leftGridZTop             = random.Next();
            double leftGridZBottom          = random.Next();
            int    leftGridHorizontalPoints = random.Next();
            int    leftGridVerticalPoints   = random.Next();

            double rightGridXLeft            = random.Next();
            double rightGridXRight           = random.Next();
            double rightGridZTop             = random.Next();
            double rightGridZBottom          = random.Next();
            int    rightGridHorizontalPoints = random.Next();
            int    rightGridVerticalPoints   = random.Next();

            double tangentLine1 = random.Next();
            double tangentLine2 = random.Next();

            var upliftVanCalculationGrid = new UpliftVanCalculationGrid
            {
                LeftGrid = new CalculationGrid
                {
                    GridXLeft   = leftGridXLeft,
                    GridXRight  = leftGridXRight,
                    GridZTop    = leftGridZTop,
                    GridZBottom = leftGridZBottom,
                    GridXNumber = leftGridHorizontalPoints,
                    GridZNumber = leftGridVerticalPoints
                },
                RightGrid = new CalculationGrid
                {
                    GridXLeft   = rightGridXLeft,
                    GridXRight  = rightGridXRight,
                    GridZTop    = rightGridZTop,
                    GridZBottom = rightGridZBottom,
                    GridXNumber = rightGridHorizontalPoints,
                    GridZNumber = rightGridVerticalPoints
                },
                TangentLines = new List <double>
                {
                    tangentLine1,
                    tangentLine2
                }
            };

            // Call
            UpliftVanCalculationGridResult result = UpliftVanCalculationGridResultCreator.Create(upliftVanCalculationGrid);

            // Assert
            AssertGrid(upliftVanCalculationGrid.LeftGrid, result.LeftGrid);
            AssertGrid(upliftVanCalculationGrid.RightGrid, result.RightGrid);
            CollectionAssert.AreEqual(upliftVanCalculationGrid.TangentLines, result.TangentLines);
        }
        public void Create_UpliftVanCalculationGridNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => UpliftVanCalculationGridResultCreator.Create(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("upliftVanCalculationGrid", exception.ParamName);
        }
Esempio n. 4
0
        public UpliftVanCalculatorResult Calculate()
        {
            IUpliftVanKernel upliftVanKernel = CalculateUpliftVan();

            return(new UpliftVanCalculatorResult(
                       UpliftVanSlidingCurveResultCreator.Create(upliftVanKernel.SlidingCurveResult),
                       UpliftVanCalculationGridResultCreator.Create(upliftVanKernel.UpliftVanCalculationGridResult),
                       MacroStabilityInwardsKernelMessagesCreator.Create(upliftVanKernel.CalculationMessages),
                       new UpliftVanCalculatorResult.ConstructionProperties
            {
                FactorOfStability = upliftVanKernel.FactorOfStability,
                ForbiddenZonesXEntryMin = upliftVanKernel.ForbiddenZonesXEntryMin,
                ForbiddenZonesXEntryMax = upliftVanKernel.ForbiddenZonesXEntryMax
            }));
        }