public void SetData_WithEmptyNameAndColor_ExpectedValuesInTable() { // Setup using (var table = new PipingSoilLayerTable()) { PipingSoilLayer soilLayer = CreatePipingSoilLayer(); soilLayer.MaterialName = string.Empty; soilLayer.Color = Color.Empty; PipingSoilLayer[] layers = { soilLayer }; // Call table.SetData(layers); // Assert PipingSoilLayer pipingSoilLayer = layers[0]; DataGridViewCellCollection rowCells = table.Rows[0].Cells; AssertColumnValueEqual("Onbekend", rowCells[nameColumnIndex].Value); AssertColumnValueEqual(Color.White, rowCells[colorColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.Top, rowCells[topColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.IsAquifer, rowCells[isAquiferColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.Permeability.Mean, rowCells[permeabilityMeanColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.Permeability.CoefficientOfVariation, rowCells[permeabilityCoefficientOfVariationColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.DiameterD70.Mean, rowCells[d70MeanColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.DiameterD70.CoefficientOfVariation, rowCells[d70CoefficientOfVariationColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.Mean, rowCells[belowPhreaticLevelWeightMeanColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.StandardDeviation, rowCells[belowPhreaticLevelWeightDeviationColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.Shift, rowCells[belowPhreaticLevelWeightShiftColumnIndex].Value); } }
public void SetData_WithData_ExpectedValuesInTable() { // Setup using (var table = new PipingSoilLayerTable()) { PipingSoilLayer[] layers = { CreatePipingSoilLayer(), CreatePipingSoilLayer(), CreatePipingSoilLayer() }; // Call table.SetData(layers); // Assert Assert.AreEqual(layers.Length, table.Rows.Count); for (var i = 0; i < table.Rows.Count; i++) { PipingSoilLayer pipingSoilLayer = layers[i]; DataGridViewCellCollection rowCells = table.Rows[i].Cells; AssertColumnValueEqual(pipingSoilLayer.MaterialName, rowCells[nameColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.Color, rowCells[colorColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.Top, rowCells[topColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.IsAquifer, rowCells[isAquiferColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.Permeability.Mean, rowCells[permeabilityMeanColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.Permeability.CoefficientOfVariation, rowCells[permeabilityCoefficientOfVariationColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.DiameterD70.Mean, rowCells[d70MeanColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.DiameterD70.CoefficientOfVariation, rowCells[d70CoefficientOfVariationColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.Mean, rowCells[belowPhreaticLevelWeightMeanColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.StandardDeviation, rowCells[belowPhreaticLevelWeightDeviationColumnIndex].Value); AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.Shift, rowCells[belowPhreaticLevelWeightShiftColumnIndex].Value); } } }
public void SetData_NoDataAlreadySet_SetNewData() { // Setup using (var table = new PipingSoilLayerTable()) { var layers = new[] { new PipingSoilLayer(2.5), new PipingSoilLayer(2.3), new PipingSoilLayer(1.1) }; // Call table.SetData(layers); // Assert Assert.AreEqual(layers.Length, table.Rows.Count); } }
public void SetData_SetNullDataAfterDataAlreadySet_ClearsData() { // Setup using (var table = new PipingSoilLayerTable()) { var layers = new[] { new PipingSoilLayer(2.5), new PipingSoilLayer(2.3), new PipingSoilLayer(1.1) }; table.SetData(layers); // Call table.SetData(null); // Assert Assert.AreEqual(0, table.Rows.Count); } }
public void Constructor_InitializesWithColumns() { // Call using (var table = new PipingSoilLayerTable()) { // 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 topColumn = table.GetColumnFromIndex(topColumnIndex); Assert.AreEqual("Topniveau\r\n[m+NAP]", topColumn.HeaderText); DataGridViewColumn isAquiferColumn = table.GetColumnFromIndex(isAquiferColumnIndex); Assert.AreEqual("Is aquifer", isAquiferColumn.HeaderText); DataGridViewColumn permeabilityMeanColumn = table.GetColumnFromIndex(permeabilityMeanColumnIndex); Assert.AreEqual("Doorlatendheid\r\n(verwachtingswaarde)\r\n[m/s]", permeabilityMeanColumn.HeaderText); DataGridViewColumn permeabilityCoefficientOfVariationColumn = table.GetColumnFromIndex(permeabilityCoefficientOfVariationColumnIndex); Assert.AreEqual("Doorlatendheid\r\n(variatiecoëfficiënt)\r\n[-]", permeabilityCoefficientOfVariationColumn.HeaderText); DataGridViewColumn d70MeanColumn = table.GetColumnFromIndex(d70MeanColumnIndex); Assert.AreEqual("d70\r\n(verwachtingswaarde)\r\n[m]", d70MeanColumn.HeaderText); DataGridViewColumn d70DeviationColumn = table.GetColumnFromIndex(d70CoefficientOfVariationColumnIndex); Assert.AreEqual("d70\r\n(variatiecoëfficiënt)\r\n[-]", d70DeviationColumn.HeaderText); DataGridViewColumn belowPhreaticLevelWeightMeanColumn = table.GetColumnFromIndex(belowPhreaticLevelWeightMeanColumnIndex); Assert.AreEqual("Verzadigd gewicht\r\n(verwachtingswaarde)\r\n[kN/m³]", belowPhreaticLevelWeightMeanColumn.HeaderText); DataGridViewColumn belowPhreaticLevelWeightDeviationColumn = table.GetColumnFromIndex(belowPhreaticLevelWeightDeviationColumnIndex); Assert.AreEqual("Verzadigd gewicht\r\n(standaardafwijking)\r\n[kN/m³]", belowPhreaticLevelWeightDeviationColumn.HeaderText); DataGridViewColumn belowPhreaticLevelWeightShiftColumn = table.GetColumnFromIndex(belowPhreaticLevelWeightShiftColumnIndex); Assert.AreEqual("Verzadigd gewicht\r\n(verschuiving)\r\n[kN/m³]", belowPhreaticLevelWeightShiftColumn.HeaderText); Assert.Throws <ArgumentOutOfRangeException>(() => table.GetColumnFromIndex(belowPhreaticLevelWeightShiftColumnIndex + 1)); CollectionAssert.IsEmpty(table.Rows); } }
public void SetData_SetNewDataAfterDataAlreadySet_ClearDataAndAddNewData() { // Setup using (var table = new PipingSoilLayerTable()) { table.SetData(new[] { new PipingSoilLayer(1.0) }); var newLayers = new[] { new PipingSoilLayer(2.5), new PipingSoilLayer(2.3), new PipingSoilLayer(1.1) }; // Call table.SetData(newLayers); // Assert Assert.AreEqual(newLayers.Length, table.Rows.Count); } }