public void GetAppliedLiquidStoredManure() { //Arrange var repository = Substitute.For <IAgriConfigurationRepository>(); repository.GetLiquidMaterialApplicationUSGallonsPerAcreRateConversion() .Returns(new List <LiquidMaterialApplicationUSGallonsPerAcreRateConversion>() { new LiquidMaterialApplicationUSGallonsPerAcreRateConversion() { ApplicationRateUnit = ApplicationRateUnits.ImperialGallonsPerAcre, USGallonsPerAcreConversion = 1.20095m } }); var convertCalculator = new ManureUnitConversionCalculator(repository); var calculator = new ManureApplicationCalculator(convertCalculator); var farmManure = new FarmManure() { sourceOfMaterialId = "StorageSystem, 1", stored_imported = NutrientAnalysisTypes.Stored }; //Act var result = calculator.GetAppliedStoredManure(_yearData, farmManure); //Assess Assert.IsNotNull(result); Assert.IsTrue(result.FieldAppliedManures.Count > 0); Assert.IsNotNull(result.FieldAppliedManures[0]); Assert.IsNotNull(result.FieldAppliedManures[0].USGallonsApplied); Assert.IsNotNull(result.FieldAppliedManures[0].USGallonsApplied.Value == 120.0950000M); Assert.IsTrue(result.TotalAnnualManureToApply == 2989m); Assert.IsTrue(result.WholePercentAppiled == 4); }
public void GetAppliedManureForStoredFarmManure() { //Arrange var repository = Substitute.For <IAgriConfigurationRepository>(); repository.GetLiquidMaterialApplicationUSGallonsPerAcreRateConversion() .Returns(new List <LiquidMaterialApplicationUSGallonsPerAcreRateConversion>() { new LiquidMaterialApplicationUSGallonsPerAcreRateConversion() { ApplicationRateUnit = ApplicationRateUnits.ImperialGallonsPerAcre, USGallonsPerAcreConversion = 1.20095m } }); var convertCalculator = new ManureUnitConversionCalculator(repository); var calculator = new ManureApplicationCalculator(convertCalculator); var farmManure = _yearData.farmManures.Single(fm => fm.id == 1); var expectedUnAllocatedMessage = "Storage System: Liquid Storage System , Material: Heavy Feeders Unallocated 2868.905000000 US gallons - 100% of Total Stored"; //Act var result = calculator.GetAppliedManure(_yearData, farmManure); //Assess Assert.IsNotNull(result); Assert.IsNotNull(result as AppliedStoredManure); Assert.IsTrue(result.FieldAppliedManures.Count > 0); Assert.IsNotNull(result.FieldAppliedManures[0]); Assert.IsNotNull(result.FieldAppliedManures[0].USGallonsApplied); Assert.IsNotNull(result.FieldAppliedManures[0].USGallonsApplied.Value == 120.0950000M); Assert.IsTrue(result.TotalAnnualManureToApply == 2989m); Assert.IsTrue(result.WholePercentAppiled == 4); Assert.IsTrue((result as AppliedStoredManure).ListUnallocatedMaterialAsPercentOfTotalStored[0] == expectedUnAllocatedMessage); }
public void GetAppliedManureForImportedManure() { //Arrange var repository = Substitute.For <IAgriConfigurationRepository>(); repository.GetSolidMaterialApplicationTonPerAcreRateConversions() .Returns(new List <SolidMaterialApplicationTonPerAcreRateConversion>() { new SolidMaterialApplicationTonPerAcreRateConversion { ApplicationRateUnit = ApplicationRateUnits.TonsPerAcre, TonsPerAcreConversion = "1" } }); var convertCalculator = new ManureUnitConversionCalculator(repository); var calculator = new ManureApplicationCalculator(convertCalculator); var farmManure = _yearData.farmManures.Single(fm => fm.id == 2); //Act var result = calculator.GetAppliedManure(_yearData, farmManure); //Assess Assert.IsNotNull(result); Assert.IsNotNull(result as AppliedImportedManure); Assert.IsTrue(result.FieldAppliedManures.Count > 0); Assert.IsNotNull(result.FieldAppliedManures[0]); Assert.IsNotNull(result.FieldAppliedManures[0].TonsApplied); Assert.IsNotNull(result.FieldAppliedManures[0].TonsApplied.Value == 100); Assert.IsTrue(result.TotalAnnualManureToApply == 1000m); Assert.IsTrue(result.WholePercentAppiled == 10); }
public void GetAppliedSolidImportedManure() { //Arrange var repository = Substitute.For <IAgriConfigurationRepository>(); repository.GetSolidMaterialApplicationTonPerAcreRateConversions() .Returns(new List <SolidMaterialApplicationTonPerAcreRateConversion>() { new SolidMaterialApplicationTonPerAcreRateConversion { ApplicationRateUnit = ApplicationRateUnits.TonsPerAcre, TonsPerAcreConversion = "1" } }); var convertCalculator = new ManureUnitConversionCalculator(repository); var calculator = new ManureApplicationCalculator(convertCalculator, repository); //var farmManure = new FarmManure {sourceOfMaterialId = "Imported, 1", stored_imported = NutrientAnalysisTypes.Imported}; var farmManure = _yearData.FarmManures.Single(fm => fm.Id == 2); //Act var result = calculator.GetAppliedImportedManure(_yearData, farmManure); //Assess result.ShouldNotBeNull(); result.FieldAppliedManures.Count.ShouldBeGreaterThan(0); result.FieldAppliedManures[0].ShouldNotBeNull(); result.FieldAppliedManures[0].TonsApplied.ShouldNotBeNull(); result.FieldAppliedManures[0].TonsApplied.Value.ShouldBe(100); result.TotalAnnualManureToApply.ShouldBe(1000m); result.WholePercentAppiled.ShouldBe(10); }