Example #1
0
        public void VerifyThatGeneratorIsCorrect()
        {
            var generator = new MassBudgetGenerator();
            var resA      = (SubSystemMassBudgetResult)generator.ComputeResult(this.MassBudgetConfig, this.MassBudgetConfig.Elements.Single(), this.option_A, this.domainOfExpertise)[0];
            var extraA    = (ExtraContribution)generator.GetExtraMassContributions(this.MassBudgetConfig, this.MassBudgetConfig.Elements.Single(), this.option_A, this.domainOfExpertise)[0];
            var resB      = (SubSystemMassBudgetResult)generator.ComputeResult(this.MassBudgetConfig, this.MassBudgetConfig.Elements.Single(), this.option_B, this.domainOfExpertise)[0];
            var extraB    = (ExtraContribution)generator.GetExtraMassContributions(this.MassBudgetConfig, this.MassBudgetConfig.Elements.Single(), this.option_B, this.domainOfExpertise)[0];

            Assert.AreEqual(15000f, resA.DryMassFromEquipment); // 10 * 1000 + 10 * 500
            Assert.AreEqual(2000f, resA.DryMassFromSubSystem);
            Assert.AreEqual(25f, resA.DryMassMarginRatioFromEquipment);
            Assert.AreEqual(20f, resA.DryMassMarginRatioFromSubSystem);
            Assert.AreEqual(18750f, resA.DryMassWithMarginFromEquipment);

            Assert.AreEqual(20000f, resB.DryMassFromEquipment); // 10 * 2000 (eqt2 is excluded)
            Assert.AreEqual(3000f, resB.DryMassFromSubSystem);
            Assert.AreEqual(25f, resB.DryMassMarginRatioFromEquipment);
            Assert.AreEqual(20f, resB.DryMassMarginRatioFromSubSystem);
            Assert.AreEqual(25000f, resB.DryMassWithMarginFromEquipment);

            Assert.AreEqual(200f, extraA.TotalContribution);
            Assert.AreEqual(400f, extraA.TotalWithMargin);
            Assert.AreEqual(200f, extraB.TotalContribution);
            Assert.AreEqual(400f, extraB.TotalWithMargin);
        }
Example #2
0
        /// <summary>
        /// Generate the budget
        /// </summary>
        protected override void ComputeBudget()
        {
            try
            {
                var computer  = new MassBudgetGenerator();
                var iteration = (Iteration)this.CurrentOption.Container;

                var results = computer.ComputeResult(this.BudgetConfig, this.RootElement, this.CurrentOption, this.Session.QuerySelectedDomainOfExpertise(iteration));

                foreach (SubSystemMassBudgetResult subSystemBudgetResult in results)
                {
                    var row = new MassBudgetRowViewModel(subSystemBudgetResult, subSystemBudgetResult.SubSystem, this.ComputeTotal);
                    this.SubSystemSummary.Add(row);
                }

                var extraMassContributions = computer.GetExtraMassContributions(this.BudgetConfig, this.RootElement, this.CurrentOption, this.Session.QuerySelectedDomainOfExpertise(iteration));
                foreach (var extraMassContribution in extraMassContributions)
                {
                    this.ExtraMassContributions.Add(new ExtraMassContributionRowViewModel(extraMassContribution));
                }

                this.Scale = results.Select(x => x.Scale).FirstOrDefault()?.Name ?? extraMassContributions.FirstOrDefault().Scale?.Name ?? "-";
            }
            catch (BudgetComputationException e)
            {
                Logger.Error("Budget Computation Error: {0}", e.Message);
            }
        }