Пример #1
0
        public void Constructor_WithArguments_ExpectedValues()
        {
            // Setup
            var mocks         = new MockRepository();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            // Call
            var handler = new ClearIllustrationPointsOfGrassCoverErosionInwardsCalculationCollectionChangeHandler(
                inquiryHelper, Enumerable.Empty <GrassCoverErosionInwardsCalculation>());

            // Assert
            Assert.IsInstanceOf <ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase>(handler);
            mocks.VerifyAll();
        }
Пример #2
0
        public void InquireConfirmation_Always_ReturnsInquiry()
        {
            // Setup
            var  random = new Random(21);
            bool expectedConfirmation = random.NextBoolean();

            var mocks         = new MockRepository();
            var inquiryHelper = mocks.StrictMock <IInquiryHelper>();

            inquiryHelper.Expect(h => h.InquireContinuation("Weet u zeker dat u alle illustratiepunten wilt wissen?")).Return(expectedConfirmation);
            mocks.ReplayAll();

            var handler = new ClearIllustrationPointsOfGrassCoverErosionInwardsCalculationCollectionChangeHandler(
                inquiryHelper, Enumerable.Empty <GrassCoverErosionInwardsCalculation>());

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

            // Assert
            Assert.AreEqual(expectedConfirmation, confirmation);
            mocks.VerifyAll();
        }
Пример #3
0
        public void ClearIllustrationPoints_Always_ReturnsAffectedCalculations()
        {
            // Setup
            var random = new Random(21);
            var overtoppingOutputWithIllustrationPoints = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(new TestGeneralResultFaultTreeIllustrationPoint()),
                                                                                             null,
                                                                                             null);
            var calculationWithOverToppingOutputWithIllustrationPoints = new GrassCoverErosionInwardsCalculation
            {
                Output = overtoppingOutputWithIllustrationPoints
            };

            var dikeHeightOutputWithIllustrationPoints = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(random.NextDouble()),
                                                                                            new TestDikeHeightOutput(new TestGeneralResultFaultTreeIllustrationPoint()),
                                                                                            null);
            var calculationWithDikeHeightWithIllustrationPoints = new GrassCoverErosionInwardsCalculation
            {
                Output = dikeHeightOutputWithIllustrationPoints
            };

            var overtoppingRateOutputWithIllustrationPoints = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(random.NextDouble()),
                                                                                                 null,
                                                                                                 new TestOvertoppingRateOutput(new TestGeneralResultFaultTreeIllustrationPoint()));
            var calculationWithOvertoppingRateWithIllustrationPoints = new GrassCoverErosionInwardsCalculation
            {
                Output = overtoppingRateOutputWithIllustrationPoints
            };

            var outputWithNoIllustrationPoints = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(random.NextDouble()),
                                                                                    null,
                                                                                    null);
            var calculationWitNoIllustrationPoints = new GrassCoverErosionInwardsCalculation
            {
                Output = outputWithNoIllustrationPoints
            };

            GrassCoverErosionInwardsCalculation[] calculations =
            {
                calculationWitNoIllustrationPoints,
                calculationWithOverToppingOutputWithIllustrationPoints,
                calculationWithOvertoppingRateWithIllustrationPoints,
                calculationWithDikeHeightWithIllustrationPoints,
                new GrassCoverErosionInwardsCalculation()
            };

            var mocks         = new MockRepository();
            var inquiryHelper = mocks.StrictMock <IInquiryHelper>();

            mocks.ReplayAll();

            var handler = new ClearIllustrationPointsOfGrassCoverErosionInwardsCalculationCollectionChangeHandler(
                inquiryHelper, calculations);

            // Call
            IEnumerable <IObservable> affectedObjects = handler.ClearIllustrationPoints();

            // Assert
            CollectionAssert.AreEquivalent(new[]
            {
                calculationWithOverToppingOutputWithIllustrationPoints,
                calculationWithOvertoppingRateWithIllustrationPoints,
                calculationWithDikeHeightWithIllustrationPoints
            }, affectedObjects);

            GrassCoverErosionInwardsCalculation[] calculationsWithOutput =
            {
                calculationWitNoIllustrationPoints,
                calculationWithOverToppingOutputWithIllustrationPoints,
                calculationWithOvertoppingRateWithIllustrationPoints,
                calculationWithDikeHeightWithIllustrationPoints
            };
            Assert.IsTrue(calculationsWithOutput.All(calc => calc.HasOutput));

            Assert.IsTrue(calculationsWithOutput.All(calc =>
            {
                GrassCoverErosionInwardsOutput output = calc.Output;

                return(!output.OvertoppingOutput.HasGeneralResult &&
                       output.DikeHeightOutput?.GeneralResult == null &&
                       output.OvertoppingRateOutput?.GeneralResult == null);
            }));
            mocks.VerifyAll();
        }