Beispiel #1
0
        public void SetData_WithData_ExpectedValuesInTable()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSoilLayerDataTable())
            {
                MacroStabilityInwardsSoilLayerData[] layers =
                {
                    CreateMacroStabilityInwardsSoilLayerData(),
                    CreateMacroStabilityInwardsSoilLayerData(),
                    CreateMacroStabilityInwardsSoilLayerData()
                };
                table.SetData(new[]
                {
                    new MacroStabilityInwardsSoilLayerData()
                });

                // Call
                table.SetData(layers);

                // Assert
                Assert.AreEqual(layers.Length, table.Rows.Count);
                for (var i = 0; i < table.Rows.Count; i++)
                {
                    MacroStabilityInwardsSoilLayerData soilLayerData = layers[i];
                    DataGridViewCellCollection         rowCells      = table.Rows[i].Cells;
                    Assert.AreEqual(soilLayerData.MaterialName,
                                    rowCells[nameColumnIndex].Value);
                    Assert.AreEqual(soilLayerData.Color,
                                    rowCells[colorColumnIndex].Value);
                    Assert.AreEqual(soilLayerData.IsAquifer,
                                    rowCells[isAquiferColumnIndex].Value);
                    AssertShiftedDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(soilLayerData),
                                                                rowCells[abovePhreaticLevelColumnIndex].Value);
                    AssertShiftedDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(soilLayerData),
                                                                rowCells[belowPhreaticLevelColumnIndex].Value);
                    Assert.AreEqual(soilLayerData.ShearStrengthModel,
                                    rowCells[shearStrengthModelColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(soilLayerData),
                                                         rowCells[cohesionColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(soilLayerData),
                                                         rowCells[frictionAngleColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(soilLayerData),
                                                         rowCells[shrearStrengthRatioColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(soilLayerData),
                                                         rowCells[strengthIncreaseExponentColumnIndex].Value);
                    Assert.AreEqual(soilLayerData.UsePop,
                                    rowCells[usePopColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(soilLayerData),
                                                         rowCells[popColumnIndex].Value);
                }
            }
        }
Beispiel #2
0
        public void SetData_NoDataAlreadySet_SetNewData()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSoilLayerDataTable())
            {
                var layers = new[]
                {
                    new MacroStabilityInwardsSoilLayerData(),
                    new MacroStabilityInwardsSoilLayerData(),
                    new MacroStabilityInwardsSoilLayerData()
                };

                // Call
                table.SetData(layers);

                // Assert
                Assert.AreEqual(layers.Length, table.Rows.Count);
            }
        }
Beispiel #3
0
        public void SetData_SetNullDataAfterDataAlreadySet_ClearsData()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSoilLayerDataTable())
            {
                var layers = new[]
                {
                    new MacroStabilityInwardsSoilLayerData(),
                    new MacroStabilityInwardsSoilLayerData(),
                    new MacroStabilityInwardsSoilLayerData()
                };
                table.SetData(layers);

                // Call
                table.SetData(null);

                // Assert
                Assert.AreEqual(0, table.Rows.Count);
            }
        }
Beispiel #4
0
        public void Constructor_InitializesWithColumns()
        {
            // Call
            using (var table = new MacroStabilityInwardsSoilLayerDataTable())
            {
                // Assert
                Assert.IsInstanceOf <DataGridViewControl>(table);

                DataGridViewColumn nameColumn = table.GetColumnFromIndex(nameColumnIndex);
                Assert.AreEqual("Naam", nameColumn.HeaderText);
                DataGridViewColumn colorColumn = table.GetColumnFromIndex(colorColumnIndex);
                Assert.AreEqual("Kleur", colorColumn.HeaderText);
                DataGridViewColumn isAquiferColumn = table.GetColumnFromIndex(isAquiferColumnIndex);
                Assert.AreEqual("Is aquifer", isAquiferColumn.HeaderText);
                DataGridViewColumn abovePhreaticLevelColumn = table.GetColumnFromIndex(abovePhreaticLevelColumnIndex);
                Assert.AreEqual("Onverzadigd gewicht\r\n[kN/m³]", abovePhreaticLevelColumn.HeaderText);
                DataGridViewColumn belowPhreaticLevelColumn = table.GetColumnFromIndex(belowPhreaticLevelColumnIndex);
                Assert.AreEqual("Verzadigd gewicht\r\n[kN/m³]", belowPhreaticLevelColumn.HeaderText);
                DataGridViewColumn shearStrengthModelColumn = table.GetColumnFromIndex(shearStrengthModelColumnIndex);
                Assert.AreEqual("Schuifsterkte model", shearStrengthModelColumn.HeaderText);
                DataGridViewColumn cohesionColumn = table.GetColumnFromIndex(cohesionColumnIndex);
                Assert.AreEqual("Cohesie\r\n[kN/m²]", cohesionColumn.HeaderText);
                DataGridViewColumn frictionAngleColumn = table.GetColumnFromIndex(frictionAngleColumnIndex);
                Assert.AreEqual("Wrijvingshoek\r\n[°]", frictionAngleColumn.HeaderText);
                DataGridViewColumn shrearStrengthRatioColumn = table.GetColumnFromIndex(shrearStrengthRatioColumnIndex);
                Assert.AreEqual("Schuifsterkte ratio (S)\r\n[-]", shrearStrengthRatioColumn.HeaderText);
                DataGridViewColumn strengthIncreaseExponentColumn = table.GetColumnFromIndex(strengthIncreaseExponentColumnIndex);
                Assert.AreEqual("Sterkte toename exp (m)\r\n[-]", strengthIncreaseExponentColumn.HeaderText);
                DataGridViewColumn usePopColumn = table.GetColumnFromIndex(usePopColumnIndex);
                Assert.AreEqual("Gebruik POP", usePopColumn.HeaderText);
                DataGridViewColumn popColumn = table.GetColumnFromIndex(popColumnIndex);
                Assert.AreEqual("POP\r\n[kN/m²]", popColumn.HeaderText);

                Assert.Throws <ArgumentOutOfRangeException>(() => table.GetColumnFromIndex(popColumnIndex + 1));

                CollectionAssert.IsEmpty(table.Rows);
            }
        }
Beispiel #5
0
        public void SetData_SetNewDataAfterDataAlreadySet_ClearDataAndAddNewData()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSoilLayerDataTable())
            {
                table.SetData(new[]
                {
                    new MacroStabilityInwardsSoilLayerData()
                });

                var newLayers = new[]
                {
                    new MacroStabilityInwardsSoilLayerData(),
                    new MacroStabilityInwardsSoilLayerData(),
                    new MacroStabilityInwardsSoilLayerData()
                };

                // Call
                table.SetData(newLayers);

                // Assert
                Assert.AreEqual(newLayers.Length, table.Rows.Count);
            }
        }