コード例 #1
0
        public void LoadParse_SimpleScenario_ParsesCorrectly()
        {
            /// Arrange
            var dairy  = new ScenarioFile();
            var field  = new ScenarioFile();
            var reader = new ScenarioReader(dairy, field);
            var sut    = new Scenario();

            var injector = new Injector();
            var s        = injector.GetSimpleScenario();

            /// Act
            reader.Load(@"Assets\simpleScenario.NIFA_dairy_scenario");
            sut = reader.Parse();

            /// Assert
            //(Only testing subset of all data)

            // [scenario]
            Assert.AreEqual(s.DetailsUrl, sut.DetailsUrl);
            Assert.AreEqual(s.StartDate.Year, sut.StartDate.Year);
            Assert.AreEqual(
                s.PathToWeatherFile,
                sut.PathToWeatherFile);
            Assert.AreEqual(s.Latitude, sut.Latitude);
            Assert.AreEqual(s.Longitude, sut.Longitude);

            // [cow_description]
            Assert.AreEqual(s.Cow.BodyMass_kg, sut.Cow.BodyMass_kg);
            Assert.AreEqual(s.Cow.IsLactating, sut.Cow.IsLactating);
            Assert.AreEqual(s.Cow.PhManure_mol_L, sut.Cow.PhManure_mol_L);
            Assert.AreEqual(s.Cow.MetabolizableEnergyDiet_MJ_d, sut.Cow.MetabolizableEnergyDiet_MJ_d);

            // [barn]
            Assert.AreEqual(s.Barn.Bedding, sut.Barn.Bedding);
            Assert.AreEqual(s.Barn.BeddingAddition, sut.Barn.BeddingAddition);
            Assert.AreEqual(s.Barn.CleaningFrequency, sut.Barn.CleaningFrequency);

            // [manure_storage] (lagoon)
            Assert.AreEqual(s.Lagoon.SurfaceArea_m2, sut.Lagoon.SurfaceArea_m2);
            Assert.AreEqual(s.Lagoon.VolumeMax_m3, sut.Lagoon.VolumeMax_m3);
            Assert.AreEqual(s.Lagoon.PH_mol_L, sut.Lagoon.PH_mol_L);

            // [fertigation_management]
            Assert.AreEqual(s.Fertigation.ApplicationMethod, sut.Fertigation.ApplicationMethod);
            Assert.AreEqual(s.Fertigation.AmountRemoved_percent, sut.Fertigation.AmountRemoved_percent);
            Assert.AreEqual(s.Fertigation.TargetField_id, sut.Fertigation.TargetField_id);
        }
コード例 #2
0
        public void ReadComplexEditWriteSimple()
        {
            // Arrange
            ScenarioFile     dairy       = new ScenarioFile();
            ScenarioFile     field       = new ScenarioFile();
            ScenarioDefaults d           = new ScenarioDefaults();
            WeatherGrabber   g           = new WeatherGrabber(@"Assets\Database\Weather");
            string           readPath    = @"Assets\complexScenario.NIFA_dairy_scenario";
            string           writePath   = @"Assets\IntegrationTest";
            string           comparePath = @"Assets\simpleScenario.NIFA_dairy_scenario";
            ScenarioReader   r           = new ScenarioReader(dairy, field);
            ScenarioWriter   w           = new ScenarioWriter(dairy, field, d, g);

            Directory.CreateDirectory(writePath);

            // Act
            r.Load(readPath);
            Scenario scenario = r.Parse();

            scenario.Description = "";

            scenario.Cow.BodyMass_kg                    = 635;
            scenario.Cow.DryMatterIntake_kg_d           = 24;
            scenario.Cow.MilkProduction_kg_d            = 34;
            scenario.Cow.CrudeProteinDiet_percent       = 17.6;
            scenario.Cow.StarchDiet_percent             = 12.83;
            scenario.Cow.AcidDetergentFiberDiet_percent = 26.08;

            scenario.Barn.ManureAlleyArea_m2 = 3000;
            scenario.Barn.NumberCows_cnt     = 1000;

            scenario.Lagoon.SurfaceArea_m2 = 142250;
            scenario.Lagoon.VolumeMax_m3   = 519213;

            scenario.Fertigation.Enabled           = false;
            scenario.Field.Id                      = "field";
            scenario.AnaerobicDigester.Enabled     = false;
            scenario.FineSeparator.Enabled         = false;
            scenario.NutrientRecovery.Enabled      = false;
            scenario.ReceiveOffFarmBiomass.Enabled = false;

            w.Write(scenario, writePath);

            // Assert
            Assert.IsTrue(
                checkFilesMatch(
                    comparePath, Path.Combine(writePath, ".NIFA_dairy_scenario")));
        }
コード例 #3
0
        public void LoadParse_ComplexScenario_ParsesCorrectly()
        {
            /// Arrange
            var dairy  = new ScenarioFile();
            var field  = new ScenarioFile();
            var reader = new ScenarioReader(dairy, field);

            var injector = new Injector();
            var s        = injector.GetComplexScenario();

            var sut = new Scenario();

            /// Act
            reader.Load(@"Assets\complexScenario.NIFA_dairy_scenario");
            sut = reader.Parse();

            /// Assert
            //(Only testing subset of all data)

            // [scenario]
            Assert.AreEqual(s.Description, sut.Description);
            Assert.AreEqual(s.StartDate.Year, sut.StartDate.Year);
            Assert.AreEqual(
                s.SimulationPeriodMode,
                sut.SimulationPeriodMode);
            Assert.AreEqual(s.Latitude, sut.Latitude);
            Assert.AreEqual(s.Longitude, sut.Longitude);

            // [barn]
            Assert.AreEqual(s.Barn.NumberCows_cnt, sut.Barn.NumberCows_cnt);
            Assert.AreEqual(s.Barn.CleaningFrequency, sut.Barn.CleaningFrequency);

            // [manure_storage] (lagoon)
            Assert.AreEqual(s.Lagoon.SurfaceArea_m2, sut.Lagoon.SurfaceArea_m2);
            Assert.AreEqual(s.Lagoon.VolumeMax_m3, sut.Lagoon.VolumeMax_m3);
            Assert.AreEqual(s.Lagoon.PH_mol_L, sut.Lagoon.PH_mol_L);

            // [manure_separator] (AD)
            Assert.AreEqual(s.AnaerobicDigester.Id, sut.AnaerobicDigester.Id);
            Assert.AreEqual(s.AnaerobicDigester.Style, sut.AnaerobicDigester.Style);
            Assert.AreEqual(s.AnaerobicDigester.SourceFacility, sut.AnaerobicDigester.SourceFacility);
            Assert.AreEqual(s.AnaerobicDigester.LiquidFacility, sut.AnaerobicDigester.LiquidFacility);
            Assert.AreEqual(s.AnaerobicDigester.SolidFacility, sut.AnaerobicDigester.SolidFacility);

            // [manure_separator] (course sep)
            Assert.AreEqual(s.CourseSeparator.Id, sut.CourseSeparator.Id);
            Assert.AreEqual(s.CourseSeparator.Style, sut.CourseSeparator.Style);
            Assert.AreEqual(s.CourseSeparator.SourceFacility, sut.CourseSeparator.SourceFacility);
            Assert.AreEqual(s.CourseSeparator.LiquidFacility, sut.CourseSeparator.LiquidFacility);
            Assert.AreEqual(s.CourseSeparator.SolidFacility, sut.CourseSeparator.SolidFacility);

            // [manure_separator] (fine sep)
            Assert.AreEqual(s.FineSeparator.Id, sut.FineSeparator.Id);
            Assert.AreEqual(s.FineSeparator.Style, sut.FineSeparator.Style);
            Assert.AreEqual(s.FineSeparator.SourceFacility, sut.FineSeparator.SourceFacility);
            Assert.AreEqual(s.FineSeparator.LiquidFacility, sut.FineSeparator.LiquidFacility);
            Assert.AreEqual(s.FineSeparator.SolidFacility, sut.FineSeparator.SolidFacility);

            // [manure_separator] (nut rec)
            Assert.AreEqual(s.NutrientRecovery.Id, sut.NutrientRecovery.Id);
            Assert.AreEqual(s.NutrientRecovery.Style, sut.NutrientRecovery.Style);
            Assert.AreEqual(s.NutrientRecovery.SourceFacility, sut.NutrientRecovery.SourceFacility);
            Assert.AreEqual(s.NutrientRecovery.LiquidFacility, sut.NutrientRecovery.LiquidFacility);
            Assert.AreEqual(s.NutrientRecovery.SolidFacility, sut.NutrientRecovery.SolidFacility);

            // [receive_off_farm_biomass:1]
            Assert.AreEqual(s.ReceiveOffFarmBiomass.ApplicationDate.Year, sut.ReceiveOffFarmBiomass.ApplicationDate.Year);
            Assert.AreEqual(s.ReceiveOffFarmBiomass.Biomatter.Mass_kg, sut.ReceiveOffFarmBiomass.Biomatter.Mass_kg);
            Assert.AreEqual(s.ReceiveOffFarmBiomass.Biomatter.CarbonOrganicResilient_kg, sut.ReceiveOffFarmBiomass.Biomatter.CarbonOrganicResilient_kg);

            // [fertigation_management]
            Assert.AreEqual(s.Fertigation.ApplicationMethod, sut.Fertigation.ApplicationMethod);
            Assert.AreEqual(s.Fertigation.AmountRemoved_percent, sut.Fertigation.AmountRemoved_percent);
            Assert.AreEqual(s.Fertigation.TargetField_id, sut.Fertigation.TargetField_id);
        }