Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultTotalViewTest.cs =================================================================== diff -u -r0a1e00c14da142df178d43f87af86906f170842b -r299e146af0e5e51db326806c46d169241cb634ca --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultTotalViewTest.cs (.../AssemblyResultTotalViewTest.cs) (revision 0a1e00c14da142df178d43f87af86906f170842b) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultTotalViewTest.cs (.../AssemblyResultTotalViewTest.cs) (revision 299e146af0e5e51db326806c46d169241cb634ca) @@ -68,6 +68,7 @@ private const string totalControlName = "totalAssemblyCategoryGroupControl"; private const string failureMechanismsWithProbabilityControlName = "failureMechanismsWithProbabilityAssemblyControl"; private const string failureMechanismsWithoutProbabilityControlName = "failureMechanismsWithoutProbabilityAssemblyControl"; + private const string assemblyResultOutdatedWarning = "Assemblageresultaat is verouderd. Druk op de \"Assemblageresultaat verversen\" knop om opnieuw te berekenen."; private Form testForm; private static IEnumerable CellFormattingStates @@ -127,24 +128,27 @@ Assert.AreEqual(DockStyle.Top, groupBox.Dock); Assert.AreEqual("Gecombineerd veiligheidsoordeel", groupBox.Text); - var tableLayOutPanel = (TableLayoutPanel) groupBox.Controls["assemblyResultTableLayoutPanel"]; - Assert.AreEqual(2, tableLayOutPanel.ColumnCount); - Assert.AreEqual(3, tableLayOutPanel.RowCount); - Assert.AreEqual(DockStyle.Fill, tableLayOutPanel.Dock); + var tableLayoutPanel = (TableLayoutPanel) groupBox.Controls["assemblyResultTableLayoutPanel"]; + Assert.AreEqual(2, tableLayoutPanel.ColumnCount); + Assert.AreEqual(3, tableLayoutPanel.RowCount); + Assert.AreEqual(DockStyle.Fill, tableLayoutPanel.Dock); - var totalResultLabel = (Label) tableLayOutPanel.GetControlFromPosition(0, 0); + var totalResultLabel = (Label) tableLayoutPanel.GetControlFromPosition(0, 0); Assert.AreEqual("Totaal", totalResultLabel.Text); - var failureMechanismsWithProbabilityLabel = (Label) tableLayOutPanel.GetControlFromPosition(0, 1); + var failureMechanismsWithProbabilityLabel = (Label) tableLayoutPanel.GetControlFromPosition(0, 1); Assert.AreEqual("Groepen 1 en 2", failureMechanismsWithProbabilityLabel.Text); - var failureMechanismsWithoutProbablityLabel = (Label) tableLayOutPanel.GetControlFromPosition(0, 2); + var failureMechanismsWithoutProbablityLabel = (Label) tableLayoutPanel.GetControlFromPosition(0, 2); Assert.AreEqual("Groepen 3 en 4", failureMechanismsWithoutProbablityLabel.Text); - Assert.IsInstanceOf(tableLayOutPanel.GetControlFromPosition(1, 0)); - Assert.IsInstanceOf(tableLayOutPanel.GetControlFromPosition(1, 1)); - Assert.IsInstanceOf(tableLayOutPanel.GetControlFromPosition(1, 2)); + Assert.IsInstanceOf(tableLayoutPanel.GetControlFromPosition(1, 0)); + Assert.IsInstanceOf(tableLayoutPanel.GetControlFromPosition(1, 1)); + Assert.IsInstanceOf(tableLayoutPanel.GetControlFromPosition(1, 2)); var datagridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl").TheObject; Assert.AreEqual(DockStyle.Fill, datagridViewControl.Dock); + ErrorProvider warningProvider = GetWarningProvider(view); + Assert.AreEqual(4, warningProvider.GetIconPadding(button)); + Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); Assert.IsNull(view.Data); @@ -387,89 +391,110 @@ } [Test] - public void GivenFormWithAssemblyResultTotalViewWithOutdatedContent_WhenRefreshingAssemblyResults_ThenRefreshButtonDisabled() + public void GivenFormWithAssemblyResultTotalViewWithOutdatedContent_WhenRefreshingAssemblyResults_ThenRefreshButtonDisabledAndWarningCleared() { // Given var assessmentSection = new AssessmentSection(new Random(21).NextEnumValue()); - using (ShowAssemblyResultTotalView(assessmentSection)) + using (AssemblyResultTotalView view = ShowAssemblyResultTotalView(assessmentSection)) { assessmentSection.NotifyObservers(); // Precondition ButtonTester buttonTester = GetRefreshAssemblyResultButtonTester(); - Assert.IsTrue(buttonTester.Properties.Enabled); + Button button = buttonTester.Properties; + Assert.IsTrue(button.Enabled); + ErrorProvider warningProvider = GetWarningProvider(view); + Assert.AreEqual(assemblyResultOutdatedWarning, warningProvider.GetError(button)); // When buttonTester.Click(); // Then - Assert.IsFalse(buttonTester.Properties.Enabled); + Assert.IsFalse(button.Enabled); + Assert.IsEmpty(warningProvider.GetError(button)); } } [Test] - public void GivenFormWithAssemblyResultTotalView_WhenAssessmentSectionNotifiesObservers_ThenRefreshButtonEnabled() + public void GivenFormWithAssemblyResultTotalView_WhenAssessmentSectionNotifiesObservers_ThenRefreshButtonEnabledAndWarningSet() { // Given var assessmentSection = new AssessmentSection(new Random(21).NextEnumValue()); - using (ShowAssemblyResultTotalView(assessmentSection)) + using (AssemblyResultTotalView view = ShowAssemblyResultTotalView(assessmentSection)) { // Precondition ButtonTester buttonTester = GetRefreshAssemblyResultButtonTester(); - Assert.IsFalse(buttonTester.Properties.Enabled); + Button button = buttonTester.Properties; + Assert.IsFalse(button.Enabled); + ErrorProvider warningProvider = GetWarningProvider(view); + Assert.IsEmpty(warningProvider.GetError(button)); // When assessmentSection.NotifyObservers(); // Then Assert.IsTrue(buttonTester.Properties.Enabled); + Assert.AreEqual(assemblyResultOutdatedWarning, warningProvider.GetError(button)); } } [Test] - public void GivenFormWithAssemblyResultTotalView_WhenFailureMechanismNotifiesObservers_ThenRefreshButtonEnabled() + public void GivenFormWithAssemblyResultTotalView_WhenFailureMechanismNotifiesObservers_ThenRefreshButtonEnabledAndWarningSet() { // Given var assessmentSection = new AssessmentSection(new Random(21).NextEnumValue()); - using (ShowAssemblyResultTotalView(assessmentSection)) + using (AssemblyResultTotalView view = ShowAssemblyResultTotalView(assessmentSection)) { // Precondition ButtonTester buttonTester = GetRefreshAssemblyResultButtonTester(); - Assert.IsFalse(buttonTester.Properties.Enabled); + Button button = buttonTester.Properties; + Assert.IsFalse(button.Enabled); + ErrorProvider warningProvider = GetWarningProvider(view); + Assert.IsEmpty(warningProvider.GetError(button)); // When assessmentSection.StabilityStoneCover.NotifyObservers(); // Then Assert.IsTrue(buttonTester.Properties.Enabled); + Assert.AreEqual(assemblyResultOutdatedWarning, warningProvider.GetError(button)); } } [Test] - public void GivenFormWithAssemblyResultTotalView_WhenCalculationNotifiesObservers_ThenRefreshButtonEnabled() + public void GivenFormWithAssemblyResultTotalView_WhenCalculationNotifiesObservers_ThenRefreshButtonEnabledAndWarningSet() { // Given var assessmentSection = new AssessmentSection(new Random(21).NextEnumValue()); var calculation = new TestHeightStructuresCalculation(); assessmentSection.HeightStructures.CalculationsGroup.Children.Add(calculation); - using (ShowAssemblyResultTotalView(assessmentSection)) + using (AssemblyResultTotalView view = ShowAssemblyResultTotalView(assessmentSection)) { // Precondition ButtonTester buttonTester = GetRefreshAssemblyResultButtonTester(); - Assert.IsFalse(buttonTester.Properties.Enabled); + Button button = buttonTester.Properties; + Assert.IsFalse(button.Enabled); + ErrorProvider warningProvider = GetWarningProvider(view); + Assert.IsEmpty(warningProvider.GetError(button)); // When calculation.NotifyObservers(); // Then Assert.IsTrue(buttonTester.Properties.Enabled); + Assert.AreEqual(assemblyResultOutdatedWarning, warningProvider.GetError(button)); } } + private static ErrorProvider GetWarningProvider(AssemblyResultTotalView resultControl) + { + return TypeUtils.GetField(resultControl, "warningProvider"); + } + #region View test helpers private AssemblyResultTotalView ShowAssemblyResultTotalView()