Пример #1
0
        public void ValidateWaveReduction_ForeshoreProfileWithGeometryForeshoreProfileUsed_ReturnsTrue()
        {
            // Setup
            const string calculationName = "calculation";

            var mocks = new MockRepository();
            var log   = mocks.StrictMock <ILog>();

            mocks.ReplayAll();

            var waveReductionConfiguration = new WaveReductionConfiguration
            {
                UseForeshoreProfile = true
            };

            // Call
            bool valid = waveReductionConfiguration.ValidateWaveReduction(new TestForeshoreProfile("voorland", new[]
            {
                new Point2D(0, 2)
            }), calculationName, log);

            // Assert
            Assert.IsTrue(valid);
            mocks.VerifyAll();
        }
Пример #2
0
        public void ValidateWaveReduction_ForeshoreProfileWithoutGeometryForeshoreProfileUsed_LogsErrorReturnsFalse()
        {
            // Setup
            const string profileName     = "voorland";
            const string calculationName = "calculation";
            const string expectedMessage = "{0} Berekening '{1}' is overgeslagen.";

            string error = $"Het opgegeven voorlandprofiel '{profileName}' heeft geen voorlandgeometrie en kan daarom niet gebruikt worden.";

            var mocks = new MockRepository();
            var log   = mocks.StrictMock <ILog>();

            log.Expect(l => l.ErrorFormat(expectedMessage, error, calculationName));
            mocks.ReplayAll();

            var waveReductionConfiguration = new WaveReductionConfiguration
            {
                UseForeshoreProfile = true
            };

            // Call
            bool valid = waveReductionConfiguration.ValidateWaveReduction(new TestForeshoreProfile(profileName), calculationName, log);

            // Assert
            Assert.IsFalse(valid);
            mocks.VerifyAll();
        }
Пример #3
0
        public void ValidateWaveReduction_NoForeshoreProfileWaveReductionWithParameter_LogsErrorReturnsFalse([Values(0, 1, 2, 3)] int propertyToSet)
        {
            // Setup
            const string calculationName = "calculation";
            const string error           = "Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen.";
            const string expectedMessage = "{0} Berekening '{1}' is overgeslagen.";

            var mocks = new MockRepository();
            var log   = mocks.StrictMock <ILog>();

            log.Expect(l => l.ErrorFormat(expectedMessage, error, calculationName));
            mocks.ReplayAll();

            var waveReductionConfiguration = new WaveReductionConfiguration();
            var random = new Random(21);

            switch (propertyToSet)
            {
            case 0:
                waveReductionConfiguration.BreakWaterType = random.NextEnumValue <ConfigurationBreakWaterType>();
                break;

            case 1:
                waveReductionConfiguration.BreakWaterHeight = random.NextDouble();
                break;

            case 2:
                waveReductionConfiguration.UseBreakWater = random.NextBoolean();
                break;

            case 3:
                waveReductionConfiguration.UseForeshoreProfile = random.NextBoolean();
                break;
            }

            // Call
            bool valid = waveReductionConfiguration.ValidateWaveReduction(null, calculationName, log);

            // Assert
            Assert.IsFalse(valid);
            mocks.VerifyAll();
        }