public void SetPropertyValueAfterConfirmation_CalculationsForTargetProbabilityWithOutput_ConfirmationRequired() { // Setup var title = ""; var message = ""; DialogBoxHandler = (name, wnd) => { var tester = new MessageBoxTester(wnd); title = tester.Title; message = tester.Text; tester.ClickCancel(); }; var handler = new HydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler( CreateCalculationsForTargetProbabilityWithAndWithoutOutput()); // Call handler.SetPropertyValueAfterConfirmation(() => {}); // Assert Assert.AreEqual("Bevestigen", title); string expectedMessage = "Als u de doelkans aanpast, dan worden alle bijbehorende hydraulische belastingen verwijderd." + Environment.NewLine + Environment.NewLine + "Weet u zeker dat u wilt doorgaan?"; Assert.AreEqual(expectedMessage, message); }
public void SetPropertyValueAfterConfirmation_CalculationsForTargetProbabilityWithAndWithoutOutput_AllCalculationOutputClearedAndReturnsAllAffectedObjects() { // Setup DialogBoxHandler = (name, wnd) => { var tester = new MessageBoxTester(wnd); tester.ClickOk(); }; HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability = CreateCalculationsForTargetProbabilityWithAndWithoutOutput(); List <IObservable> expectedAffectedObjects = calculationsForTargetProbability.HydraulicBoundaryLocationCalculations .Where(hblc => hblc.HasOutput) .Cast <IObservable>() .ToList(); expectedAffectedObjects.Add(calculationsForTargetProbability); var handler = new HydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler(calculationsForTargetProbability); IEnumerable <IObservable> affectedObjects = null; // Call void Call() => affectedObjects = handler.SetPropertyValueAfterConfirmation(() => {}); // Assert var expectedMessages = new[] { "Alle bijbehorende hydraulische belastingen zijn verwijderd." }; TestHelper.AssertLogMessagesAreGenerated(Call, expectedMessages, 1); CollectionAssert.IsEmpty(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations.Where(c => c.HasOutput)); CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }
public void SetPropertyValueAfterConfirmation_CalculationsForTargetProbabilityWithoutOutput_NoConfirmationRequired() { // Setup var handler = new HydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler( CreateCalculationsForTargetProbabilityWithoutOutput()); // Call handler.SetPropertyValueAfterConfirmation(() => {}); // Assert // No assert as the check is to verify whether a modal dialog is spawned }
public void SetPropertyValueAfterConfirmation_SetValueNull_ThrowArgumentNullException() { // Setup var handler = new HydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler( new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1)); // Call void Call() => handler.SetPropertyValueAfterConfirmation(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("setValue", exception.ParamName); }
public void SetPropertyValueAfterConfirmation_ConfirmationNotRequired_HandlerExecuted() { // Setup var handler = new HydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler( CreateCalculationsForTargetProbabilityWithoutOutput()); var handlerExecuted = false; // Call handler.SetPropertyValueAfterConfirmation(() => handlerExecuted = true); // Assert Assert.IsTrue(handlerExecuted); }
public void SetPropertyValueAfterConfirmation_ConfirmationGiven_HandlerExecuted() { // Setup DialogBoxHandler = (name, wnd) => { var tester = new MessageBoxTester(wnd); tester.ClickOk(); }; var handler = new HydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler( CreateCalculationsForTargetProbabilityWithAndWithoutOutput()); var handlerExecuted = false; // Call handler.SetPropertyValueAfterConfirmation(() => handlerExecuted = true); // Assert Assert.IsTrue(handlerExecuted); }
public void SetPropertyValueAfterConfirmation_CalculationsForTargetProbabilityWithoutOutput_ReturnsAffectedObjectsAndDoesNotLog() { // Setup HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability = CreateCalculationsForTargetProbabilityWithoutOutput(); var handler = new HydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler( calculationsForTargetProbability); HydraulicBoundaryLocationCalculationsForTargetProbability[] expectedAffectedObjects = { calculationsForTargetProbability }; IEnumerable <IObservable> affectedObjects = null; // Call void Call() => affectedObjects = handler.SetPropertyValueAfterConfirmation(() => {}); // Assert TestHelper.AssertLogMessagesCount(Call, 0); CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }
public void SetPropertyValueAfterConfirmation_ConfirmationNotGiven_SetValueNotCalledReturnsNoAffectedObjects() { // Setup DialogBoxHandler = (name, wnd) => { var tester = new MessageBoxTester(wnd); tester.ClickCancel(); }; HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability = CreateCalculationsForTargetProbabilityWithAndWithoutOutput(); var handler = new HydraulicBoundaryLocationCalculationsForTargetProbabilityChangeHandler(calculationsForTargetProbability); var propertySet = 0; // Call IEnumerable <IObservable> affectedObjects = handler.SetPropertyValueAfterConfirmation(() => propertySet++); // Assert Assert.AreEqual(0, propertySet); Assert.AreEqual(2, calculationsForTargetProbability.HydraulicBoundaryLocationCalculations.Count(c => c.HasOutput)); CollectionAssert.IsEmpty(affectedObjects); }