// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Windows.Forms; using Core.Common.Base; using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.Views; using Ringtoets.Common.Primitives; using Ringtoets.Integration.Data.StandAlone; using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Integration.Forms.Views.SectionResultRows; using Ringtoets.Integration.Forms.Views.SectionResultViews; namespace Ringtoets.Integration.Forms.Test.Views.SectionResultViews { [TestFixture] public class WaterPressureAsphaltCoverResultViewTest { private const int nameColumnIndex = 0; private const int simpleAssessmentResultIndex = 1; private const int tailorMadeAssessmentResultIndex = 2; private const int columnCount = 3; [Test] public void Constructor_ExpectedValues() { // Setup var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); // Call using (var view = new WaterPressureAsphaltCoverResultView(failureMechanism.SectionResults, failureMechanism)) { // Assert Assert.IsInstanceOf>(view); Assert.IsNull(view.Data); Assert.AreSame(failureMechanism, view.FailureMechanism); } } [Test] public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() { // Given using (var form = new Form()) using (var view = new WaterPressureAsphaltCoverResultView(new ObservableList(), new WaterPressureAsphaltCoverFailureMechanism())) { form.Controls.Add(view); form.Show(); // Then var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; Assert.AreEqual(columnCount, dataGridView.ColumnCount); Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); } } [Test] public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() { // Setup var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1")); // Call using (var form = new Form()) using (var view = new WaterPressureAsphaltCoverResultView(failureMechanism.SectionResults, failureMechanism)) { form.Controls.Add(view); form.Show(); // Assert var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(1, rows.Count); DataGridViewCellCollection cells = rows[0].Cells; Assert.AreEqual(columnCount, cells.Count); Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); Assert.AreEqual(TailorMadeAssessmentResultType.None, cells[tailorMadeAssessmentResultIndex].Value); } } } }