예제 #1
0
        public void Wepp_WriteScenarioFiles_FromVerificationLocations()
        {
            // Arrange
            CsvHandler         reader      = new CsvHandler();
            IBuildErosionModel builder     = new WeppBuilder();
            ScenarioHandler    writer      = new ScenarioHandler();
            string             currentDate = DateTime.Now.ToString("yyyyMMdd");
            string             expectedZip = $"Assets\\output\\wepp_{currentDate}.zip";
            string             writePath   = $"Assets\\output\\wepp_{currentDate}";

            // Act
            List <string> actual = builder.BuildScenarios(
                reader.ReadCsipLocationFile(@"Assets\location_verification_10.csv"),
                builder.GetTemplate(),
                builder.GetRotations());

            writer.WriteScenariosZip(actual, writePath);

            // Assert
            Assert.True(File.Exists(expectedZip));

            // Cleanup
            if (File.Exists(expectedZip))
            {
                File.Delete(expectedZip);
            }
            if (Directory.Exists(writePath))
            {
                Directory.Delete(writePath, true);
            }
        }
예제 #2
0
        public void Wepp_Build_ValidInput10Locs_ExpectedResults()
        {
            // Arrange
            CsvHandler         reader = new CsvHandler();
            IBuildErosionModel sut    = new WeppBuilder();

            // Act
            List <string> actual = sut.BuildScenarios(
                reader.ReadCsipLocationFile(@"Assets\location_verification_10.csv"),
                sut.GetTemplate(),
                sut.GetRotations());

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(33, actual.Count);
        }
예제 #3
0
        public void Wepp_Build_ValidInput01Loc_ExpectedResults()
        {
            // Arrange
            CsvHandler         reader = new CsvHandler();
            IBuildErosionModel sut    = new WeppBuilder();

            // Act
            List <string> actual = sut.BuildScenarios(
                reader.ReadCsipLocationFile(@"Assets\location_verification_01.csv"),
                sut.GetTemplate(),
                sut.GetRotations());

            // Assert
            string strippedJson = Regex.Replace(actual.FirstOrDefault(), @"\s+", "");

            // Check soil cokey, soil slope, soil length, rotation soil length
            Assert.Contains("{\"name\":\"soilPtr\",\"value\":[\"17389235\"]}", strippedJson);
            Assert.Contains("{\"name\":\"slope_steepness\",\"value\":4.0}", strippedJson);
            Assert.Contains("{\"name\":\"length\",\"value\":350.0}", strippedJson);
            Assert.Contains("{\"duration\":2,\"length\":350.0", strippedJson);
        }