Skip to content

Commit

Permalink
Disable scaling up of emissions
Browse files Browse the repository at this point in the history
  • Loading branch information
holos-aafc committed Apr 19, 2024
1 parent 2f93376 commit 13c03fc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
14 changes: 4 additions & 10 deletions H.Core.Test/Services/Animals/ScaleUpServiceTest.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using H.Core.Calculators.Infrastructure;
using H.Core.Emissions.Results;

using H.Core.Enumerations;
using H.Core.Models.Animals.Sheep;
using H.Core.Models.Animals;
using H.Core.Models;
using H.Core.Providers.Animals.Table_28;
using H.Core.Services.Animals;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Collections.Generic;
using H.Core.Providers.Animals.Table_28;

namespace H.Core.Test.Services.Animals
{
Expand Down Expand Up @@ -54,15 +48,15 @@ public void TestCleanup()
[TestMethod]
public void ShouldScaleUpReturnsTrue()
{
var result = _scaleUpService.ShouldScaleUp(true, AnimalType.BeefBackgrounderHeifer, ProductionStages.GrowingAndFinishing, ComponentType.Backgrounding);
var result = _scaleUpService.ShouldScaleUp(true, AnimalType.BeefBackgrounderHeifer, ProductionStages.GrowingAndFinishing, ComponentType.Backgrounding, new Farm() { Defaults = new Defaults() { ScaleUpEmissionsEnabled = true } });

Assert.IsTrue(result);
}

[TestMethod]
public void ShouldScaleUpReturnsFalse()
{
var result = _scaleUpService.ShouldScaleUp(true, AnimalType.BeefCowLactating, ProductionStages.Lactating, ComponentType.CowCalf);
var result = _scaleUpService.ShouldScaleUp(true, AnimalType.BeefCowLactating, ProductionStages.Lactating, ComponentType.CowCalf, new Farm() {Defaults = new Defaults() {ScaleUpEmissionsEnabled = true}});

Assert.IsFalse(result);
}
Expand Down
8 changes: 8 additions & 0 deletions H.Core/Models/Defaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public class Defaults : ModelBase
private PumpType _defaulPumpType;
private double _pumpEmissionsFactor;

private bool _scaleUpEmissionsEnabled;

#endregion

#region Constructors
Expand Down Expand Up @@ -991,6 +993,12 @@ public TillageType RunInPeriodTillageType
set => SetProperty(ref _runInPeriodTillageType, value);
}

public bool ScaleUpEmissionsEnabled
{
get => _scaleUpEmissionsEnabled;
set => SetProperty(ref _scaleUpEmissionsEnabled, value);
}

#endregion

#region Public Methods
Expand Down
2 changes: 1 addition & 1 deletion H.Core/Services/Animals/IScaleUpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IScaleUpService
#region Public Methods

bool ShouldScaleUp(bool isAnnualReport, AnimalType animalType, ProductionStages productionStage,
ComponentType? componentType);
ComponentType? componentType, Farm farm);
double ScaleUpEmissions(double emissions, double numberOfDaysRest, double numberOfDaysInCycle);

#endregion
Expand Down
7 changes: 6 additions & 1 deletion H.Core/Services/Animals/ScaleUpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ public ScaleUpService(ITable_28_Production_Days_Provider table28ProductionDaysPr
#region Public Methods

public bool ShouldScaleUp(bool isAnnualReport, AnimalType animalType, ProductionStages productionStage,
ComponentType? componentType)
ComponentType? componentType, Farm farm)
{
if (farm.Defaults.ScaleUpEmissionsEnabled == false)
{
return false;
}

if (isAnnualReport == false)
{
// Emissions are only scaled up when reporting annually
Expand Down

0 comments on commit 13c03fc

Please sign in to comment.