Exemple #1
0
        public void RequireConfirmation_FailureMechanismWithCalculationWithOutput_ReturnTrue()
        {
            // Setup
            var mockRepository = new MockRepository();
            var inquiryHandler = mockRepository.StrictMock <IInquiryHelper>();

            var calculation = mockRepository.StrictMock <ICalculation>();

            calculation.Expect(calc => calc.HasOutput).Return(true);
            mockRepository.ReplayAll();

            var failureMechanism = new TestCalculatableFailureMechanism(new[]
            {
                calculation
            });

            var handler = new FailureMechanismCalculationChangeHandler(failureMechanism, string.Empty, inquiryHandler);

            // Call
            bool requireConfirmation = handler.RequireConfirmation();

            // Assert
            Assert.IsTrue(requireConfirmation);
            mockRepository.VerifyAll();
        }
Exemple #2
0
        public void Constructor_WithParameters_ImplementsExpectedInterface()
        {
            // Setup
            var mockRepository   = new MockRepository();
            var inquiryHandler   = mockRepository.Stub <IInquiryHelper>();
            var failureMechanism = mockRepository.Stub <ICalculatableFailureMechanism>();

            mockRepository.ReplayAll();

            // Call
            var handler = new FailureMechanismCalculationChangeHandler(failureMechanism, string.Empty, inquiryHandler);

            // Assert
            Assert.IsInstanceOf <IConfirmDataChangeHandler>(handler);
            mockRepository.VerifyAll();
        }
Exemple #3
0
        public void RequireConfirmation_FailureMechanismWithoutCalculations_ReturnsFalse()
        {
            // Setup
            var mockRepository = new MockRepository();
            var inquiryHandler = mockRepository.StrictMock <IInquiryHelper>();

            mockRepository.ReplayAll();

            var failureMechanism = new TestCalculatableFailureMechanism(Enumerable.Empty <ICalculation>());

            var handler = new FailureMechanismCalculationChangeHandler(failureMechanism, string.Empty, inquiryHandler);

            // Call
            bool requireConfirmation = handler.RequireConfirmation();

            // Assert
            Assert.IsFalse(requireConfirmation);
            mockRepository.VerifyAll();
        }
Exemple #4
0
        public void InquireConfirmation_Always_ShowsConfirmationDialogReturnResultOfInquiry(string message, bool expectedResult)
        {
            // Setup
            var mockRepository = new MockRepository();
            var inquiryHandler = mockRepository.StrictMock <IInquiryHelper>();

            inquiryHandler.Expect(ih => ih.InquireContinuation(message)).Return(expectedResult);
            var failureMechanism = mockRepository.Stub <ICalculatableFailureMechanism>();

            mockRepository.ReplayAll();

            var handler = new FailureMechanismCalculationChangeHandler(failureMechanism, message, inquiryHandler);

            // Call
            bool result = handler.InquireConfirmation();

            // Assert
            Assert.AreEqual(expectedResult, result);
            mockRepository.VerifyAll();
        }
Exemple #5
0
        private bool VerifyStructuresShouldUpdate(ClosingStructuresFailureMechanism failureMechanism, string query)
        {
            var changeHandler = new FailureMechanismCalculationChangeHandler(failureMechanism, query, GetInquiryHelper());

            return(!changeHandler.RequireConfirmation() || changeHandler.InquireConfirmation());
        }