public void PublicTrySetScenarioParameters_ScenarioWithRelevantSet_DataAddedToModelReturnsTrue()
        {
            // Setup
            var random = new Random(45);
            bool isRelevant = random.NextBoolean();

            var mockRepository = new MockRepository();
            var calculationScenario = mockRepository.StrictMock<ICalculationScenario>();
            calculationScenario.Expect(cs => cs.IsRelevant).SetPropertyWithArgument(isRelevant);
            mockRepository.ReplayAll();

            var importer = new CalculationConfigurationImporter(Path.Combine(readerPath, "validConfiguration.xml"),
                                                                new CalculationGroup());

            // Call
            bool successful = importer.PublicTrySetScenarioParameters(new ScenarioConfiguration
            {
                IsRelevant = isRelevant
            }, calculationScenario);

            // Assert
            Assert.IsTrue(successful);

            mockRepository.VerifyAll();
        }
        public void PublicTrySetScenarioParameters_ScenarioWithNaNContribution_LogMessageReturnsFalse()
        {
            // Setup
            const string calculationScenarioName = "calculationScenario";

            var mockRepository = new MockRepository();
            var calculationScenario = mockRepository.StrictMock<ICalculationScenario>();
            calculationScenario.Expect(cs => cs.Name).Return(calculationScenarioName);
            mockRepository.ReplayAll();

            var importer = new CalculationConfigurationImporter(Path.Combine(readerPath, "validConfiguration.xml"),
                                                                new CalculationGroup());

            // Call
            var successful = true;

            void Call() => successful = importer.PublicTrySetScenarioParameters(new ScenarioConfiguration
            {
                Contribution = double.NaN
            }, calculationScenario);

            // Assert
            string expectedMessage = "De bijdrage van een berekening moet een getal tussen 0 en 100 zijn. " +
                                     $"Berekening '{calculationScenarioName}' is overgeslagen.";
            TestHelper.AssertLogMessageWithLevelIsGenerated(Call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 1);
            Assert.IsFalse(successful);

            mockRepository.VerifyAll();
        }
        public void PublicTrySetScenarioParameters_ScenarioWithContributionSet_DataAddedToModelReturnsTrue()
        {
            // Setup
            var random = new Random(45);
            double contribution = random.NextDouble();

            var mockRepository = new MockRepository();
            var calculationScenario = mockRepository.StrictMock<ICalculationScenario>();
            calculationScenario.Expect(cs => cs.Contribution)
                               .SetPropertyWithArgument((RoundedDouble) (contribution / 100));
            mockRepository.ReplayAll();

            var importer = new CalculationConfigurationImporter(Path.Combine(readerPath, "validConfiguration.xml"),
                                                                new CalculationGroup());

            // Call
            bool successful = importer.PublicTrySetScenarioParameters(new ScenarioConfiguration
            {
                Contribution = contribution
            }, calculationScenario);

            // Assert
            Assert.IsTrue(successful);

            mockRepository.VerifyAll();
        }
        public void PublicTrySetScenarioParameters_NoScenario_NoDataAddedToModelReturnsTrue()
        {
            // Setup
            var mockRepository = new MockRepository();
            var calculationScenario = mockRepository.StrictMock<ICalculationScenario>();
            mockRepository.ReplayAll();

            var importer = new CalculationConfigurationImporter(Path.Combine(readerPath, "validConfiguration.xml"),
                                                                new CalculationGroup());

            // Call
            bool successful = importer.PublicTrySetScenarioParameters(null, calculationScenario);

            // Assert
            Assert.IsTrue(successful);

            mockRepository.VerifyAll();
        }