public void SetPropertyValueAfterConfirmation_IfConfirmationRequiredThenGiven_SetValueCalledAffectedObjectsReturned(ChangePropertyTestCase testCase)
        {
            // Setup
            bool dialogBoxWillBeShown = testCase.Calculation.HasOutput;

            var title   = "";
            var message = "";

            if (dialogBoxWillBeShown)
            {
                DialogBoxHandler = (name, wnd) =>
                {
                    var tester = new MessageBoxTester(wnd);
                    title   = tester.Title;
                    message = tester.Text;

                    tester.ClickOk();
                };
            }

            var calculationInput = new TestCalculationInput();
            var propertySet      = 0;

            var changeHandler = new ObservablePropertyChangeHandler(testCase.Calculation, calculationInput);

            // Precondition
            Assert.AreEqual(dialogBoxWillBeShown, testCase.Calculation.HasOutput);

            // Call
            IEnumerable <IObservable> affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(() => propertySet++);

            // Assert
            var expectedAffectedObjects = new List <IObservable>();

            if (dialogBoxWillBeShown)
            {
                Assert.AreEqual("Bevestigen", title);
                string expectedMessage = "Als u een parameter in deze berekening wijzigt, zal de uitvoer van deze berekening verwijderd worden."
                                         + Environment.NewLine + Environment.NewLine +
                                         "Weet u zeker dat u wilt doorgaan?";
                Assert.AreEqual(expectedMessage, message);

                expectedAffectedObjects.Add(testCase.Calculation);
            }

            expectedAffectedObjects.Add(calculationInput);
            CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
            Assert.AreEqual(1, propertySet);
            Assert.IsFalse(testCase.Calculation.HasOutput);
        }
        public void SetPropertyValueAfterConfirmation_IfConfirmationRequiredThenGiven_SetValueCalledAffectedObjectsReturned(ChangePropertyTestCase testCase)
        {
            // Setup
            bool dialogBoxWillBeShown = testCase.ExpectedAffectedCalculations.Any();

            var title   = "";
            var message = "";

            if (dialogBoxWillBeShown)
            {
                DialogBoxHandler = (name, wnd) =>
                {
                    var tester = new MessageBoxTester(wnd);
                    title   = tester.Title;
                    message = tester.Text;

                    tester.ClickOk();
                };
            }

            var testFailureMechanism = new TestCalculatableFailureMechanism(testCase.Calculations);
            var propertySet          = 0;

            var changeHandler = new FailureMechanismPropertyChangeHandler <ICalculatableFailureMechanism>();

            // Precondition
            Assert.IsTrue(testCase.ExpectedAffectedCalculations.All(c => c.HasOutput));

            // Call
            IEnumerable <IObservable> affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(
                testFailureMechanism,
                3,
                (f, v) => propertySet++);

            // Assert
            if (dialogBoxWillBeShown)
            {
                Assert.AreEqual("Bevestigen", title);
                string expectedMessage = "Als u deze parameter wijzigt, zal de uitvoer van alle berekeningen in dit faalmechanisme verwijderd worden."
                                         + Environment.NewLine + Environment.NewLine +
                                         "Weet u zeker dat u wilt doorgaan?";
                Assert.AreEqual(expectedMessage, message);
            }

            Assert.AreEqual(1, propertySet);
            var expectedAffectedObjects = new List <IObservable>(testCase.ExpectedAffectedCalculations)
            {
                testFailureMechanism
            };

            CollectionAssert.AreEqual(expectedAffectedObjects, affectedObjects);
            Assert.IsTrue(testCase.Calculations.All(c => !c.HasOutput));
        }