public void UpdateObserver_PreviousCalculationUpdated_ChartTitleNotUpdated()
        {
            // Setup
            using (var view = new PipingInputView())
            {
                const string initialName = "Initial name";
                const string updatedName = "Updated name";

                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    Name = initialName
                };

                view.Data = calculation;

                // Precondition
                Assert.AreEqual(initialName, view.Chart.ChartTitle);

                view.Data = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    Name = initialName
                };

                calculation.Name = updatedName;

                // Call
                calculation.NotifyObservers();

                // Assert
                Assert.AreEqual(initialName, view.Chart.ChartTitle);
            }
        }
        public void GivenPipingFailureMechanismResultView_WhenCalculationNotifiesObservers_ThenDataGridViewUpdatedAndAssemblyPerformed()
        {
            // Given
            var failureMechanism = new PipingFailureMechanism();

            FailureMechanismTestHelper.SetSections(failureMechanism, new[]
            {
                FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1")
            });

            var calculationScenario = new TestPipingCalculationScenario();

            failureMechanism.CalculationsGroup.Children.Add(calculationScenario);

            using (new AssemblyToolCalculatorFactoryConfig())
                using (ShowFailureMechanismResultsView(failureMechanism))
                {
                    var testFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                    FailureMechanismSectionAssemblyCalculatorStub failureMechanismSectionAssemblyCalculator = testFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
                    failureMechanismSectionAssemblyCalculator.FailureMechanismSectionAssemblyResultOutput = new FailureMechanismSectionAssemblyResultWrapper(
                        new FailureMechanismSectionAssemblyResult(1, 1, 1, FailureMechanismSectionAssemblyGroup.III),
                        AssemblyMethod.BOI0A1, AssemblyMethod.BOI0B1);

                    FailureMechanismAssemblyCalculatorStub failureMechanismAssemblyCalculator  = testFactory.LastCreatedFailureMechanismAssemblyCalculator;
                    IEnumerable <FailureMechanismSectionAssemblyResult> initialCalculatorInput = failureMechanismAssemblyCalculator.SectionAssemblyResultsInput
                                                                                                 .ToArray();

                    var          rowsChanged  = false;
                    DataGridView dataGridView = GetDataGridView();
                    dataGridView.Rows.CollectionChanged += (sender, args) => rowsChanged = true;

                    // Precondition
                    Assert.IsFalse(rowsChanged);

                    // When
                    calculationScenario.NotifyObservers();

                    // Then
                    Assert.IsTrue(rowsChanged);
                    IEnumerable <FailureMechanismSectionAssemblyResult> updatedCalculatorInput = failureMechanismAssemblyCalculator.SectionAssemblyResultsInput
                                                                                                 .ToArray();
                    CollectionAssert.AreNotEqual(initialCalculatorInput, updatedCalculatorInput);
                }
        }