示例#1
0
        public void Create_WithMessages_ReturnOnlyWarningAndErrorMacroStabilityInwardsKernelMessages()
        {
            // Setup
            Message[] logMessages =
            {
                CreateMessage(MessageType.Info,    "Calculation Info"),
                CreateMessage(MessageType.Warning, "Calculation Warning"),
                CreateMessage(MessageType.Error,   "Calculation Error")
            };

            // Call
            IEnumerable <MacroStabilityInwardsKernelMessage> kernelMessages = MacroStabilityInwardsKernelMessagesCreator.Create(logMessages);

            // Assert
            Assert.AreEqual(2, kernelMessages.Count());
            MacroStabilityInwardsKernelMessage firstMessage = kernelMessages.ElementAt(0);

            Assert.AreEqual("Calculation Warning", firstMessage.Message);
            Assert.AreEqual(MacroStabilityInwardsKernelMessageType.Warning, firstMessage.Type);

            MacroStabilityInwardsKernelMessage secondMessage = kernelMessages.ElementAt(1);

            Assert.AreEqual("Calculation Error", secondMessage.Message);
            Assert.AreEqual(MacroStabilityInwardsKernelMessageType.Error, secondMessage.Type);
        }
示例#2
0
        public void Create_MessagesNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => MacroStabilityInwardsKernelMessagesCreator.Create(null);

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

            Assert.AreEqual("messages", exception.ParamName);
        }
示例#3
0
 public IEnumerable <MacroStabilityInwardsKernelMessage> Validate()
 {
     try
     {
         IUpliftVanKernel upliftVanKernel = CreateUpliftVanKernel();
         return(MacroStabilityInwardsKernelMessagesCreator.Create(upliftVanKernel.Validate().ToArray()));
     }
     catch (UpliftVanKernelWrapperException e)
     {
         throw new UpliftVanCalculatorException(e.Message, e);
     }
 }
示例#4
0
        public IEnumerable <MacroStabilityInwardsKernelMessage> Validate()
        {
            IWaternetKernel waternetKernel = GetWaternetKernel();

            try
            {
                return(MacroStabilityInwardsKernelMessagesCreator.Create(waternetKernel.Validate().ToArray()));
            }
            catch (WaternetKernelWrapperException e)
            {
                throw new WaternetCalculatorException(e.Message, e);
            }
        }
示例#5
0
        private IUpliftVanKernel CalculateUpliftVan()
        {
            IUpliftVanKernel upliftVanKernel = CreateUpliftVanKernel();

            try
            {
                upliftVanKernel.Calculate();
            }
            catch (UpliftVanKernelWrapperException e)
            {
                throw new UpliftVanCalculatorException(e.Message, e, MacroStabilityInwardsKernelMessagesCreator.Create(e.Messages));
            }

            return(upliftVanKernel);
        }
示例#6
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
            }));
        }
示例#7
0
        public void Create_MessageTextNull_ReturnsMacroStabilityInwardsKernelMessageWithUnknownText()
        {
            // Setup
            Message[] logMessages =
            {
                CreateMessage(MessageType.Error, null)
            };

            // Call
            IEnumerable <MacroStabilityInwardsKernelMessage> kernelMessages = MacroStabilityInwardsKernelMessagesCreator.Create(logMessages);

            // Assert
            MacroStabilityInwardsKernelMessage kernelMessage = kernelMessages.Single();

            Assert.AreEqual("Onbekend", kernelMessage.Message);
            Assert.AreEqual(MacroStabilityInwardsKernelMessageType.Error, kernelMessage.Type);
        }