Beispiel #1
0
        public void GetCoefficientOfVariation_RowHasStandardDeviation_LogWarningReturnConvertedVarianceValue()
        {
            // Setup
            var messageProvider = mocks.Stub <IImporterMessageProvider>();
            var updateStrategy  = mocks.Stub <IStructureUpdateStrategy <TestStructure> >();

            mocks.ReplayAll();

            string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                         Path.Combine("Structures", "CorrectFiles", "Kunstwerken.shp"));

            var referenceLine = new ReferenceLine();
            var importTarget  = new StructureCollection <TestStructure>();

            var importer = new TestStructuresImporter(importTarget,
                                                      referenceLine,
                                                      filePath,
                                                      updateStrategy,
                                                      messageProvider);

            var parameter = new StructuresParameterRow
            {
                AlphanumericValue = "",
                LineNumber        = 3,
                LocationId        = "A",
                NumericalValue    = -3,
                ParameterId       = "B",
                VarianceType      = VarianceType.StandardDeviation,
                VarianceValue     = 2.3
            };

            const string structureName = "<naam kunstwerk>";

            // Call
            var    coefficientOfVariation = (RoundedDouble)0.0;
            Action call = () => coefficientOfVariation = importer.GetCoefficientOfVariation(parameter, structureName);

            // Assert
            string expectedMessage = string.Format(
                "De variatie voor parameter '{2}' van kunstwerk '{0}' ({1}) wordt omgerekend in een variatiecoëfficiënt (regel {3}).",
                structureName, parameter.LocationId, parameter.ParameterId, parameter.LineNumber);

            TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn), 1);
            double expectedStandardDeviation = parameter.VarianceValue / Math.Abs(parameter.NumericalValue);

            Assert.AreEqual(expectedStandardDeviation, coefficientOfVariation, coefficientOfVariation.GetAccuracy());
        }
Beispiel #2
0
        public void GetCoefficientOfVariation_RowHasCoefficientOfVariation_ReturnVarianceValue()
        {
            // Setup
            var messageProvider = mocks.Stub <IImporterMessageProvider>();
            var updateStrategy  = mocks.Stub <IStructureUpdateStrategy <TestStructure> >();

            mocks.ReplayAll();

            string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                         Path.Combine("Structures", "CorrectFiles", "Kunstwerken.shp"));

            var referenceLine = new ReferenceLine();
            var importTarget  = new StructureCollection <TestStructure>();

            var importer = new TestStructuresImporter(importTarget,
                                                      referenceLine,
                                                      filePath,
                                                      updateStrategy,
                                                      messageProvider);

            var parameter = new StructuresParameterRow
            {
                AlphanumericValue = "",
                LineNumber        = 3,
                LocationId        = "A",
                NumericalValue    = -3,
                ParameterId       = "B",
                VarianceType      = VarianceType.CoefficientOfVariation,
                VarianceValue     = 2.3
            };

            // Call
            var    coefficientOfVariation = (RoundedDouble)0.0;
            Action call = () => coefficientOfVariation = importer.GetCoefficientOfVariation(parameter, "<naam kunstwerk>");

            // Assert
            TestHelper.AssertLogMessagesCount(call, 0);
            Assert.AreEqual(parameter.VarianceValue, coefficientOfVariation, coefficientOfVariation.GetAccuracy());
        }