Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion API/Services/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public static Graph ToGraph(this Models.Soil soil, double[] thickness = null,
.Multiply(soil.Water.Thickness).Sum();

// To stop the sw line crossing over ll, constrain it to ll.
var swConstainedToLL = sw.LowerConstraint(ll);
var swConstainedToLL = sw?.LowerConstraint(ll);
return SoilGraph.Create(soil.Name, soil.Water.Thickness.ToMidPoints(), soil.Water.AirDry, soil.Water.LL15,
soil.Water.DUL, soil.Water.SAT, ll, cropName, pawc, paw, thickness?.ToMidPoints(), swConstainedToLL);
}
Expand Down
13 changes: 13 additions & 0 deletions Tests/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,17 @@ public void ToAPSIMSoil_ShouldPopulateAllMembers()
var apsimSoilXml = soil.ToAPSIMSoil().ToXML();
Assert.That(apsimSoilXml, Is.EqualTo(ResourceFile.Get("Tests.testsoil1.apsim.xml")));
}

[Test]
public void ToGraph_ShouldWorkWithoutSWSpecified()
{
var soil = ResourceFile.FromResourceXML<API.Models.Soil>("Tests.testsoil1.xml");

var graph = soil.ToGraph();
Assert.That(graph, Is.Not.Null);

// should be 5 graph series:
// shaded bucket, ll, airdry, dul, sat
Assert.That(graph.Series.Count, Is.EqualTo(5));
}
}